Message 1 of 4
Open DWG dialog window from excel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Is it possible?
I have got this far:
Open autocad application
Check if app is open
if not - MsgBox
Set the open document to the active document
if that returns "nothing" then
open file dialog box <<< this where I fall over 😞
Sub OpenFileCAD()
Dim AcadApp As Object
Dim acadDoc As Object
Dim acadAppVar As Integer
acadAppVar = 0
'--------------------------------------------------------------------
'Check if AutoCAD application is open. If is not opened create a new instance and make it visible.
On Error Resume Next
Set AcadApp = GetObject(, "AutoCAD.Application")
If AcadApp Is Nothing Then
Set AcadApp = CreateObject("AutoCAD.Application")
AcadApp.Visible = True
End If
'--------------------------------------------------------------------
'Check (again) if there is an AutoCAD object.
If AcadApp Is Nothing Then
MsgBox "Message", vbCritical, "AutoCAD Error"
Exit Sub
Else: acadAppVar = 1 '<<< Used later on
End If
On Error GoTo 0
'--------------------------------------------------------------------
'Check if there is an active drawing.
On Error Resume Next
Set acadDoc = AcadApp.ActiveDocument
On Error GoTo 0
'No active drawing found. Create a new one.
If acadDoc Is Nothing Then
' ¯\_(?)_/¯
'acadApp.Visible = True
End If
End SubI have spent most of today and all of yesterday trying to figure this out, I have done many a search so please forgive me if I missed something obvious.
Thanks for you time! 🙂