|
Tutorials
|
|
There are situations where it can be usefull to load a AutoCad project from Excel. You don't have to set the AutoCad reference in Excel. The only thing the code does is startup AutoCad and load another Project.
Show/Hidden vbnet code Public Function RUNproject(ByVal PROJECTPATH As String, ByVal MACRONAME As String)
Dim AcadRunning As Boolean
'On Error GoTo Err_Control
AcadRunning = IsAutoCADOpen()
If AcadRunning Then
Set objAcad = GetObject(, "AutoCAD.Application")
Else
Set objAcad = CreateObject("AutoCAD.Application")
End If
objAcad.Visible = True
Set ThisDrawing = objAcad.ActiveDocument
Dim FileName As String
FileName = PROJECTPATH
' Load a sample VBA project DVB file create with AutoCAD
objAcad.LoadDVB FileName
' Run the macro
objAcad.RunMacro MACRONAME 'enter the module and routine/function name
Exit_Here:
Exit Sub
Err_Control:
MsgBox Err.Description
Resume Exit_Here
End Function
Test the function with a code that looks somewhat like this:
Show/Hidden vbnet code Sub TSTproject()
'Test the function
RUNproject "C:\Testproject.dvb", "MODULENAME.ROUTINENAME"
End Sub
|
Comments
RSS feed for comments to this post.