WD: Using AppActivate to Switch to Another ApplicationLast reviewed: February 2, 1998Article ID: Q72287 |
The information in this article applies to:
SUMMARYThis article contains an example macro that switches the focus from Microsoft Word to another application; when it is finished, the macro returns the focus to Word. What the macro does while switching between applications is up to the individual user. The AppActivate statement activates the specified window in an application other than Microsoft Word. Use AppActivate to switch to another application that is already running or that you have started by using Shell. To activate a window within Word, use the Activate command. NOTE: If the other application is minimized, this macro will not maximize that application; it simply gives that application the focus and then returns the focus to Word for Windows.
MORE INFORMATION
Word 97 for Windows or Word 98 Macintosh EditionFor more information about switching focus to another application using Word 97 for Windows or Word 98 Macintosh Edition, while in the Visual Basic for Applications Editor, click the Office Assistant, type "AppActivate" (without the quotation marks), click Search, and then click to view "AppActivate Statement". For examples of how to do this in Word 97 or Word 98, click "Example." NOTE: If the Assistant is hidden, click the Office Assistant button on the Standard toolbar. If Microsoft Visual Basic Help is not installed on your computer, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q120802 TITLE : Office: How to Add/Remove a Single Office Program or Component Word Versions 7.x and EarlierThe following is the text of the macro:
Sub Main ActiveWin$ = WindowName$() 'get the title of the current window AppActivate "Microsoft Excel", 1 Activate ActiveWin$ End SubThe WordBasic AppActivate syntax is as follows:
AppActivate WindowText$ [,Immediate]NOTE: Many applications append the name of the working file to the application name used in the window title bar. For example, the Windows Cardfile application might have window names such as:
Cardfile - (untitled) Cardfile - PHONE.CRDIn this case the following AppActivate command should include the complete window text string:
AppActivate "Cardfile - PHONE.CRD", 1Microsoft Excel includes the working file name in the windows title bar when the spreadsheet window is maximized. There are other methods to return the focus to Word for Windows. The main advantage of this method is its simplicity. When the macro returns the focus, Word for Windows will be in the exact state that it was left in prior to running the macro.
REFERENCES"Microsoft Word for Windows Technical Reference," page 29 "Microsoft Word for Windows and OS/2 Technical Reference," pages 128-129
|
Additional query words: word6 winword word7 word95 winword winword2
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |