Microsoft KB Archive/118944

{|
 * width="100%"|

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

 * }

-

The information in this article applies to:


 * Microsoft Excel for Windows, version 5.0

-

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:

 The "No Documents" menu bar is still displayed when the dialog box is dismissed (even though there may be a document in the application window once the dialog box is closed).  If you attempt to exit Microsoft Excel in this state, you may receive a general protection (GP) fault, and receive the error message:

Excel caused a General Protection Fault in module EXCEL.EXE at 0042:0CBE



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
 Close all open documents. Create a new workbook by clicking New on the File menu. On the Insert menu, click Macro, and then click Module to insert a new module in the workbook.  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  On the Insert menu, click Macro, and then click Dialog to insert a dialog sheet in the workbook.</li> Hide this workbook by clicking Hide on the Window menu.

The application window should be empty (there are no documents visible).</li> On the File menu, click Macro, select the ShowDialogToAddWorkbook macro, and click Run. When the dialog box is displayed, click OK.</li></ol>

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:


 * A dialog box button with the Cancel property is chosen.
 * The dialog box is closed by pressing the ESC key.
 * The dialog box is closed by choosing Close from the control menu in the upper-left corner of the dialog box.

Additional query words:

Keywords : kbcode

Version : 5.00

Platform : WINDOWS

Issue type :

Technology :