Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Other running applications?
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00699321
Message ID:
00699453
Views:
17
>Could someone please tell me how I can get a handle to Word and then activate it. I've been trying to use FindWindow but that requires the exact window name.
>

You might want to look into the WSH's Wscript.Shell AppActivate method. It can take as an argument either the name of the executable you wish to run, or a portion of the application's Top-Level Window title text (the preferences are for leading matches, then trailing matches, then embedded matches) and will activate the Window moving the application to the foreground (on Win2K and WinXP, minimized apps are flashed, to request that the operator intervene; reading the documentation is critical to the proper use.)

A simple example:
oWSH = CREATEOBJ('Wscript.Shell')
oWSH.AppActive('WORD.EXE')
A word (bad pun) of warning - MS Word is an MDI app; several apparent instances of Word may all actually be a single instance with multiple top-level windows. It can make both selection and termination (and for that matter, detection of termination) of a specific instance of Word run against a document difficult to manipulate.

See the articles that George Tasker and I wrote on the WSH, or any of the web sites in my .sig block, for further information on WSH. Do plan to read the docs; it's a case where it's very easy to hurt yourself out of arrogance or ignorance of the consequences of using the call or using partial matches of the window text.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform