| Open AutoCad file by Excel macro |
|
|
|
| Tutorials | |||
|
The routine below opens a AutoCad file even if AutoCad is closed. 1 Sub main() 2 '*********************************** 3 '*** Code From VisibleVisual.com *** 4 '*********************************** 5 Dim ACAD As Object 6 Dim NewFile As Object 7 Dim MyAcadPath As String 8 Dim bReadOnly As Boolean 9 10 On Error Resume Next 11 ACAD = GetObject(, "ACAD.Application") 12 If (Err <> 0) Then 13 Err.Clear() 14 ACAD = CreateObject("autocad.Application") 15 If (Err <> 0) Then 16 MsgBox("Could Not Load AutoCAD!", vbExclamation) 17 End 18 End If 19 End If 20 21 'If you want to see AutoCAD on screen 22 'ACAD.Visible = True 23 24 MyAcadPath = "c:\Temp\Drawing2.dwg" 25 bReadOnly = True 26 NewFile = ACAD.Documents.Open(MyAcadPath, bReadOnly) 27 28 If (NewFile Is Nothing) Then 29 ErrorMessage: 30 If NewFile = "False" Then End 31 MsgBox("Could not find the required spreadsheet that should be located at" & vbCr & MyAcadPath & vbCr & "Please rename or relocate the specified file as needed.") 32 End 33 End If 34 35 'Close AutoCAD Process 36 'ACAD.Quit 37 38 ACAD = Nothing 39 NewFile = Nothing 40 41 End Sub
|



Comments
i copied everything 7 on MyAcadPath = "c:\Temp\Drawin g2.dwg" i specified my drawing but everytime i click the button nothing happens... please help...
RSS feed for comments to this post