jrice174
Civil/Environmental
- Nov 8, 2004
- 129
From Excel I want to use the GetOpenFilename method to open an Autocad file. Below is what I have but it certainly doesn't work. any ideas?
Dim NewFile As String
Dim ACAD As Object
Dim MyPath As String
On Error Resume Next
Set ACAD = GetObject(, "ACAD.Application")
If Err <> 0 Then
Err.Clear
Set ACAD = CreateObject("autocad.Application")
If Err <> 0 Then
MsgBox "Could Not Load AutoCAD!", vbExclamation
End
End If
End If
On Error GoTo ErrorMessage
' Section 2. Get Excel ready to make the data available.
''MyPath = "C:\Documents and Settings\HP_Administrator\Desktop\SampleSpreadsheet.xls"
''MyPath = "G:\Jerico stuff\marketing\Form Letter\Local Designers.xls"
MyPath = "G:\Programming\Ares PDQ\A0631621.dwg"
NewFile = ACAD.Application.GetOpenFilename("Drawing File (*.dwg), *.dwg", , "Select Drawing File", , False)
MsgBox NewFile
'Set ExcelSheet = Excel.workbooks.Open(NewFile)
GoTo PastErrorMessage
ErrorMessage:
If NewFile = "False" Then End
MsgBox "Could not find the required spreadsheet that should be located at" & vbCr & MyPath & vbCr & "Please rename or relocate the specified file as needed."
End
PastErrorMessage:
Dim NewFile As String
Dim ACAD As Object
Dim MyPath As String
On Error Resume Next
Set ACAD = GetObject(, "ACAD.Application")
If Err <> 0 Then
Err.Clear
Set ACAD = CreateObject("autocad.Application")
If Err <> 0 Then
MsgBox "Could Not Load AutoCAD!", vbExclamation
End
End If
End If
On Error GoTo ErrorMessage
' Section 2. Get Excel ready to make the data available.
''MyPath = "C:\Documents and Settings\HP_Administrator\Desktop\SampleSpreadsheet.xls"
''MyPath = "G:\Jerico stuff\marketing\Form Letter\Local Designers.xls"
MyPath = "G:\Programming\Ares PDQ\A0631621.dwg"
NewFile = ACAD.Application.GetOpenFilename("Drawing File (*.dwg), *.dwg", , "Select Drawing File", , False)
MsgBox NewFile
'Set ExcelSheet = Excel.workbooks.Open(NewFile)
GoTo PastErrorMessage
ErrorMessage:
If NewFile = "False" Then End
MsgBox "Could not find the required spreadsheet that should be located at" & vbCr & MyPath & vbCr & "Please rename or relocate the specified file as needed."
End
PastErrorMessage: