Solved

VBA AppActivate("[AppWindowTitle]")

Posted on 2014-12-17
6
461 Views
Last Modified: 2014-12-19
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.
0
Comment
Question by:RWayneH
6 Comments
 
LVL 24

Assisted Solution

by:Bitsqueezer
Bitsqueezer earned 150 total points
ID: 40506440
Hi,

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.

Cheers,

Christian
0
 
LVL 18

Assisted Solution

by:Simon
Simon earned 150 total points
ID: 40506472
You might want to try it with the TaskID return value of shell instead:
http://msdn.microsoft.com/en-us/library/office/gg278643%28v=office.14%29.aspx
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.
0
 
LVL 45

Accepted Solution

by:
aikimark earned 200 total points
ID: 40506702
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.
0
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 

Author Comment

by:RWayneH
ID: 40509437
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.
0
 
LVL 45

Expert Comment

by:aikimark
ID: 40509468
yes. leading characters.  in VBA, you should be able to use VB's Appactivate statement.
0
 

Author Closing Comment

by:RWayneH
ID: 40509909
Worked!  Thanks for the help. -R-
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question