Maximize / Make it visible Autocad instance minimized in the task bar

Maximize / Make it visible Autocad instance minimized in the task bar

nicolamora
Contributor Contributor
443 Views
3 Replies
Message 1 of 4

Maximize / Make it visible Autocad instance minimized in the task bar

nicolamora
Contributor
Contributor

I cannot find the code to make an instance of Autocad already open but minimized in the task bar, visible. Any idea? 

I already tried without success:

 

AppActivate "AutoCAD"

 

        ACAD.Activate
        ACAD.SetFocus
        ACAD.Visible = True

Thanks

0 Likes
444 Views
3 Replies
Replies (3)
Message 2 of 4

norman.yuan
Mentor
Mentor

You need to as your question in a meaningful context: describe what kind of application you are using/writing, where your tried code  runs.

 

This forum is for AutoCAD VBA discussion. Are you running VBA code inside AutoCAD? If so, how come AutoCAD becomes minimize while your code is running?

 

If your code runs outside AutoCAD (stand-alone EXE of your development, or from other apps, such as MS office's VBA, then you need to use AutoCAD COM API to obtain the running AutoCAD session as AcadApplication, which can be easily approaced by calling GetObject(), if there is only one running AutoCAD session. Once you have an AcadApplication object/instance, you can simply set cadApp.WindowState to acMax.

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 4

nicolamora
Contributor
Contributor

Thanks Norman for your reply. I'm running a code from Inventor VBA to Autocad app. 

I'm not sure why but with cadApp.WindowState = acMax, only the Autocad command bar is visualized. 

I was able to maximize Autocad with "cadApp.WindowState = 3" instead. 

 

Here below, a piece of code that works for me. It open Autocad, if not already open, and maximize it if minimized on the task bar.    

 

 

Dim ACAD As Object
On Error Resume Next
Set ACAD = GetObject(, "autocad.application") 'gives error 429 if Autocad is not open

If Err.Number = 429 Then
Err.Clear
Set ACAD = CreateObject("autocad.Application")
ACAD.Visible = True

End If

If Not ACAD Is Nothing Then
ACAD.Visible = True
ACAD.WindowState = 3
Else: MsgBox "Unable to retrieve ACAD."
End If

0 Likes
Message 4 of 4

seabrahenrique
Advocate
Advocate

In my tests here the folowing simple code below can maximize my AutoCAD in taskbar using a Excel macro (for example):

 

Sub MaximizeAutoCAD()

Dim acadApp As Object
Set acadApp = GetObject(, "AutoCAD.Application")
acadApp.WindowState = 3

End Sub

 

This doesn't work for you?

0 Likes