Microsoft Knowledge Base |
|
XL: Error Message Using Name of Constant with Show Method |
|
|
Last reviewed: June 26, 1997
Article ID: Q114183 |
|
The information in this article applies to:
SUMMARYWhen you use the Show method of the Dialog Object in a Visual Basic macro in Microsoft Excel, and you use the name of a built-in constant as the value of an argument, the following error message may appear:
Run-time error '1004': Show method of Dialog class failed CAUSEThis behavior is by design in Microsoft Excel. You cannot use the name of a built-in constant as an argument for the Show method of the Dialog Object. Because some constants are used as arguments for multiple dialog boxes, there is no way to uniquely identify a constant by name.
WORKAROUNDSTo avoid receiving this error message when you use arguments with the Show method of the Dialog object, use the value of the argument as determined by the Microsoft Excel version 4.0 macro command instead of the name of the constant. For example, if you are using the Show method to display the Save As dialog box, and you want to save the file to the Microsoft Excel Workbook file format, use the following code:
Sub SaveAs_Dlg()
Application.Dialogs(xlDialogSaveAs).Show arg1:="TEST.XLS", arg2:=1
End Sub
When you run this macro, the Save As dialog box appears and Microsoft
Excel Workbook is selected in the Save File As Type list because the
value of the Microsoft Excel workbook file format argument is 1.
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 engineers 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.
MORE INFORMATIONTo find the value of an individual argument to use with the Show method of the Dialog object in Microsoft Excel, do the following:
|
|
Additional query words: 5.00 5.00a 5.00c 7.00 7.00a
©1997 Microsoft Corporation. All rights reserved. Legal Notices. |