Solved

VBA AppActivate("[AppWindowTitle]")

Posted on 2014-12-17
6
407 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:SimonAdept
SimonAdept 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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
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 simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now