问题描述
应用程序(例如:acad.exe [AutoCAD])位于任务栏中(状态为Minimum),我想在VBA中恢复或最大化它。
$ b这是可能的吗?
任何关于这些的提示都会有很大的帮助。
我尝试过:
使用下面的代码,我得到了任务栏中可用应用程序的窗口名称:
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:
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
例如:
Basic_vba.pdf - Adobe Acrobat Reader DC
AutoCAD Mechanical 2016 - [sample_model.dwg]
20170424.txt - TeraPad
...
Example:
Basic_vba.pdf - Adobe Acrobat Reader DC
AutoCAD Mechanical 2016 - [sample_model.dwg]
20170424.txt - TeraPad
...
推荐答案
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:
AppActivate "AutoCAD"
最后说明:我不是AutoCAD的专家。
Final note: i'm not an expert of AutoCAD.
这篇关于如何使用VBA从任务栏打开应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!