Solved

VBA AppActivate("[AppWindowTitle]")

Posted on 2014-12-17
6
486 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel if statement 3 15
IDENTIFY THE CERO  OR ONE  OR BOTH IN AN NUMBER ?? 29 37
Strategy Mapping Excel WB/WS 2 24
V-Lookup 11 16
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
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.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

790 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