Microsoft KB Archive/309351

= BUG: DefaultTab Property of Word's PageSetup Dialog Box Doesn't Set Layout Tab =

Article ID: 309351

Article Last Modified on 10/23/2006

-

APPLIES TO


 * Microsoft Word 2002 Standard Edition

-



This article was previously published under Q309351



SYMPTOMS
Automation code in Word to set the DefaultTab property for the PageSetup dialog box object to the Layout tab does not appear to work, or selects the wrong tab when the dialog box is shown.

For example, the following Visual Basic for Applications (VBA) code displays the PageSetup dialog box in Word 2002, but the Layout tab is not selected: Sub Test Dialogs(wdDialogFilePageSetup).DefaultTab = wdDialogFilePageSetupTabLayout Dialogs(wdDialogFilePageSetup).Show End Sub The same code runs as expected in Word 97 and Word 2000.



CAUSE
If you release the object and reacquire it (as in the code in the &quot;Symptoms&quot; section), the value for the tab setting is persisted and reloaded when the object is reacquired. In Word 2002, the PageSetup dialog box combines the Paper Size and Paper Source tabs into a single tab called Paper. Because of this change, the Layout tab is the third tab instead of the fourth tab in the dialog box. The DefaultTab property attempts to switch the dialog box to the fourth tab, which is the wrong tab.

In Word clients that have an East Asian language installed, the dialog box has a fourth tab named Document Grid, and the code selects this tab by mistake. For clients without such a language installed, the first tab appears but draws incorrectly.



RESOLUTION
To work around the problem, always set the DefaultTab property on the same object instance on which you call the Show method, as follows: Sub Test With Dialogs(wdDialogFilePageSetup) .DefaultTab = wdDialogFilePageSetupTabLayout .Show End With End Sub



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce Behavior
 Start Word 2002, and press ALT+F11 to open the Visual Basic Editor. On the Insert menu, click Module.  Add the following code to the module: Sub Test Dialogs(wdDialogFilePageSetup).DefaultTab = wdDialogFilePageSetupTabLayout Dialogs(wdDialogFilePageSetup).Show End Sub  On the Tools menu, click Macros, select Test, and then click Run.

Keywords: kbautomation kbbug kbpending KB309351

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.