Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The application (for example: acad.exe [AutoCAD]) is in the taskbar(status is Minimum), I want to restore or maximize it in VBA.

Is that possible?

Any tips on these will be great help.

What I have tried:

With the code below I got the window names of the applications that are available in the Taskbar:
VB
Private Sub AppActivates(WindowName As String)

    Dim WD, task, n As Long
    Set WD = CreateObject("Word.Application")

    For Each task In WD.Tasks
        MsgBox task.Name
    Next

    WD.Quit
    Set WD = Nothing

End Sub


Example:

Basic_vba.pdf - Adobe Acrobat Reader DC
AutoCAD Mechanical 2016 - [sample_model.dwg]
20170424.txt - TeraPad
...
Posted
Updated 25-Apr-17 11:32am
v4
Comments
Richard MacCutchan 25-Apr-17 4:41am    
You need to send a Windows message to the application that will make it active. But then what?

1 solution

Take a look here: Using Visual Basic with AutoCAD - Andrew G. Roe - Google Books[^]
or here: AutoCAD 2004 VBA: A Programmer's Reference - Joe Sutphin - Google Books[^]


VB
Private Sub ActivateAutoCad()
 
    Dim ACApp As Object

    On Error Resume Next 
    Set ACApp = GetObject(,"AutoCAD.Application")
    If Err Then
        Err.Clear
        MsgBox("AutoCAD application is not running")
    Else
        ACApp.Activate
        'or
        'ACApp.SetFocus
        'or
        'ACApp.Visible = True
    End If

    Set ACApp = Nothing
 
End Sub


Another option is to use a statement like this:
VB
AppActivate "AutoCAD"


Final note: i'm not an expert of AutoCAD.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900