by Allen Wyatt
(last updated January 17, 2020)
There are many, many times when I work with two files at a time in Word. For instance, I may be reading one document and comparing it to another (and I don't want to use the Compare Documents feature). I always try to keep the document I am modifying in the top part of my screen, and the other document in the bottom part. Call it a personality quirk, but I find it easier to use the windows this way.
It can be a pain to repeatedly adjust the position of the windows and make sure that the proper file is at the top of the screen. Therefore, I developed a macro to handle this situation. You can use this handy little macro to switch which window is "on top" if you have two windows displayed on the screen. You will probably want to assign this to a toolbar button or a shortcut key, as it will be of little use if you need to keep calling it from the macro list. The following will work in Word 97:
Sub FlipFlop() If Windows.Count = 2 Then WordBasic.NextWindow WindowArrangeAll End If End Sub
If you are using a later version of Word, then macro needs to changed just slightly:
Sub FlipFlop() If Windows.Count = 2 Then WordBasic.NextWindow Windows.Arrange End If End Sub
Notice that these macros only work if (and only if) there are two windows on the screen. If there is more or less, then the macro does nothing at all.
There are undoubtedly VBA experts reading this tip who will notice right away that the command WordBasic.NextWindow could have been replaced with ActiveWindow.Next.Activate. (The VBA help indicates this is the VBA equivalent of the NextWindow command in WordBasic.) An interesting thing happens when you do this, however—the macro does not work. You can try this yourself by following these steps:
When you do these steps, you will notice that the macro (the one that Word just created for you) bombs out on one of the ActiveWindow.Next.Activate commands. Probably a good bug item for Redmond, but the way around it is to use the WordBasic.NextWindow command instead.
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (972) applies to Microsoft Word 97, 2000, 2002, and 2003.
Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!
A great place for your macro to display status information is, well, in the status bar. Displaying the information is ...Discover More
Toolbar buttons can have a different appearance depending on their stateâ€"whether they have been clicked or not. This ...Discover More
Do you need to step through a table, cell by cell, in a macro? It's easy to do using the Move method, as described in ...Discover More
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Got a version of Word that uses the menu interface (Word 97, Word 2000, Word 2002, or Word 2003)? This site is for you! If you use a later version of Word, visit our WordTips site focusing on the ribbon interface.