XL5: "No Documents" Menu Bar Displayed When Document Is Open

ID: Q118944

5.00 WINDOWS kbprog kbcode

The information in this article applies to:

SYMPTOMS

In Microsoft Excel version 5.0, when you run a Visual Basic, Applications Edition, macro that displays a dialog box while there are no documents in the application window, and if a control is assigned to the dialog box that opens, unhides, or adds a workbook when the dialog box is dismissed or hidden, you may experience the following problems:

WORKAROUND

To work around this problem, create a macro that displays the dialog box and, if OK is clicked, adds a new workbook after the dialog box is hidden. When you assign macros to controls on a dialog sheet, the macro is run and then the dialog box is hidden.

Microsoft provides examples of Visual Basic for Applications procedures for illustration only, without warranty either expressed or implied, including, but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. The Visual Basic procedures in this article are provided 'as is' and Microsoft does not guarantee that they can be used in all situations. While Microsoft support professionals can help explain the functionality of a particular macro, they will not modify these examples to provide added functionality, nor will they help you construct macros to meet your specific needs. If you have limited programming experience, you may want to consult one of the Microsoft Solution Providers. Solution Providers offer a wide range of fee-based services, including creating custom macros. For more information about Microsoft Solution Providers, call Microsoft Customer Information Service at (800) 426-9400.

Example

1. Close all open documents.

2. Create a new workbook by clicking New on the File menu.

3. On the Insert menu, click Macro, and then click Module to insert a

   new module in the workbook.

4. Type the following code on the module sheet:

     Sub ShowDialogToAddWorkbook()
     Dim Response as Integer
                 Response = Thisworkbook.DialogSheets(1).Show
          If Response then Workbooks.Add
     End Sub

5. On the Insert menu, click Macro, and then click Dialog to insert a
   dialog sheet in the workbook.

6. Hide this workbook by clicking Hide on the Window menu.

The application window should be empty (there are no documents visible).

7. On the File menu, click Macro, select the ShowDialogToAddWorkbook

   macro, and click Run. When the dialog box is displayed, click OK.

A new workbook will appear in the window and the worksheet menu bar will be displayed.

Alternate Workaround

Set the Visible property of the Workbook where your Dialogs(x).Show statement is contained to True prior to executing the Dialogs(x).Show statement. Return it to False after the dialog is dismissed.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem was corrected in Microsoft Excel for Windows version 5.0c.

MORE INFORMATION

The Show method for dialog boxes will return a value of False (or 0) under the following conditions:

KBCategory: kbprg kbcode KBSubcategory: kbcode

Additional reference words: 5.00

Keywords          : kbcode 
Version           : 5.00
Platform          : WINDOWS

Last Reviewed: May 17, 1999