VBA AppActivate("[AppWindowTitle]")

AppActivate ("QuickTest Professional - [C:\QTP\TestingScenarios\ThirdParty\TP01 - Customer Change - New Catalog Code]")

Why would this all of a sudden stop working in VBA?  It has been working for some time and now today it is not.  Not even sure what may have changed to cause this.  The file is there.  Another weird happening is that in QTP all references to the File.open....  it did not like either.  I had to re-record/reset the file.open's and those started working.  Also there were other QTP references that I had to reset too, when I did a file import/export functions in QTP.  Any ideas?  Please advise and thanks.
Who is Participating?
aikimarkConnect With a Mentor Commented:
AppActivate will work with just the leading characters.  Unless you have multiple QTP windows open, you don't need to include the file name in the string.
BitsqueezerConnect With a Mentor Commented:

normally this happens if a reference is broken in the reference list. See VBA editor, Tools, References. If the checked references contains a "MISSED:" then this is a broken reference which you need to repair.

In such cases sometimes normal VBA functions like Date or Left etc. suddenly doesn't work anymore.

That happens mostly if a new version of a library was installed on your computer which you used in your references and Office couldn't automatically update the reference automatically. Try to uncheck the broken reference and search the entry in the list or, if it is not in the list, browse for the library file on your own (see in the old reference by clicking on it before you uncheck it to see where Office tried to search for the file, normally the new one is on the same location).

In case of Windows 64 bit sometimes a library which was in System32 is now in SysWoW64.


SimonConnect With a Mentor Commented:
You might want to try it with the TaskID return value of shell instead:
AppActivate can also use the return value of the Shell function.
MyAppID = Shell("C:\WORD\WINWORD.EXE", 1) ' Run Microsoft Word.
AppActivate MyAppID ' Activate Microsoft
 ' Word.
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

RWayneHAuthor Commented:
So I replaced it with:
Set WshShell = CreateObject("WScript.Shell")
WshShell.AppActivate "QuickTest Professional - [C:\QTP\TestingScenarios\ThirdParty\TP01 - Customer Change - New Catalog Code]"

If this will work with the leading chars?  Would the rewrite be?
Set WshShell = CreateObject("WScript.Shell")
WshShell.AppActivate "QuickTest Professional"

testing now.
yes. leading characters.  in VBA, you should be able to use VB's Appactivate statement.
RWayneHAuthor Commented:
Worked!  Thanks for the help. -R-
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.