开发者

Helping AppActivate find my program

I built a VBA script that activates my companies enterprise database software and takes a screenshot of error messages to compile them and send them to our IT department when they pop up.

The problem is that it has about a 30 percent chance of not finding the database program.

I am using AppActivate, and having it reiterate the command with different variations on the name. (I borrowed this c开发者_如何学JAVAhunk of code from elsewhere when my AppActivate was missing 60-70% of the time.)

"PROGname v2 - [title of menu user is on]" is the menu-bar name for the program. Is there something I can be doing to grab it every time?

Sub ActivateWin()
'Activates The Program by window name
    On Error Resume Next          'we ignore all errors until we reach last AppActivate
    AppActivate ("PROG")
    If Err.Number = 5 Then Err = 0:  AppActivate ("PROGname v2")
    If Err.Number = 5 Then Err = 0:  AppActivate ("PRO")
    If Err.Number = 5 Then Err = 0:  AppActivate ("P")
    If Err.Number = 5 Then Err = 0:  AppActivate ("prog")
    If Err.Number = 5 Then Err = 0:  MsgBox "PROGname not found. Please go yell at MYNAME!"
End Sub


Maybe you could try another way with the FindWindow command (some other info here).

In order to find which class refer to your progam, you can use this addin: http://www.xcelfiles.com/API_06.html or get inspired by the code and customize it to your needs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜