如何使用VBA从任务栏打开应用程序? [英] How to open appication from taskbar with VBA?

查看:140
本文介绍了如何使用VBA从任务栏打开应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应用程序(例如: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 - Adob​​e 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
...

推荐答案

看看这里:在AutoCAD中使用Visual Basic - Andrew G. Roe - Google图书 [ ^ ]

或此处: AutoCAD 2004 VBA:程序员参考 - Joe Sutphin - Google图书 [ ^ ]





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[^]


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从任务栏打开应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆