Check if autoCAD is open

Check if autoCAD is open

Anonymous
Not applicable
2,614 Views
2 Replies
Message 1 of 3

Check if autoCAD is open

Anonymous
Not applicable

Hello there!

 

How can I writhe a VBA to check if autoCAD Application is open, and when YES then call a Sub and when NO make a message box that autoCAD is close.

Below have you a VBA that I whant to integrate in Excel.

Sub runsub(control As IRibbonControl)

Dim acadApp As AcadApplication
Dim acadDoc As AcadDocument

If acadApp Is Nothing Then
MsgBox "AutoCAD is closed"
Else
Call Zeichnung
End If
End Sub

Can you please help me out?

 

Best regards

Alex

 

0 Likes
2,615 Views
2 Replies
Replies (2)
Message 2 of 3

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

you can use GetObject() to try to get a connection to an running instance of AutoCAD.

But in case you don't get a positive result that does not mean that AutoCAD was not started, it could also be that AutoCAD is running, just not responding (current active with something).

Check the list of processes for "acad.exe" could also be a test.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 3 of 3

Jonathan3891
Advisor
Advisor

 

Sub sbACAD()
Dim objAutoCAD As Object

On Error Resume Next
Set objAutoCAD = GetObject(, "AutoCAD.Application")
On Error GoTo 0

If objAutoCAD Is Nothing Then
          
MsgBox "AutoCAD is not running", vbOKOnly, "Error"
          
Else: AppActivate "AutoCAD"
objAutoCAD.WindowState = 3

End If
End Sub

 


Jonathan Norton
Blog | Linkedin
0 Likes