Showing xlDialogFormatChart Causes Run-Time Error

ID: Q136522


The information in this article applies to:
  • Microsoft Excel for Windows, versions 5.0, 5.0c
  • Microsoft Excel for Windows NT, version 5.0
  • Microsoft Excel for Windows 95, version 7.0


SYMPTOMS

When you use the following line of code in a Visual Basic, Applications Edition, procedure


   Application.Dialogs(xlDialogFormatChart).Show 
you will receive the following error message:
Run-time error 1004: Show method of Dialog class failed


CAUSE

xlDialogFormatChart is the equivalent of clicking Options in the Format Chart Type dialog box. The Application.Dialog show method is the Microsoft Excel 5.0 Visual Basic for Applications equivalent to the Microsoft Excel 4.0 macro (XLM) command FORMAT.CHART?(1). If the XLM command requires one or more arguments, then so does the Visual Basic for Applications method.


RESOLUTION

The following Visual Basic for Applications code produces the results as intended by using the Application.Dialogs(xlDialogFormatChart).Show.

NOTE: This code assumes that you have an embedded chart named "Chart 1" on a worksheet.

Microsoft provides examples of Visual Basic 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. This Visual Basic procedure is provided 'as is' and Microsoft does not guarantee that it can be used in all situations. Microsoft does not support modifications of this procedure to suit customer requirements for a particular purpose.


   Sub FormatGroup()
      'Select the actual chart.
      ActiveSheet.DrawingObjects("Chart 1").Select
      'Activate the chart.
       ActiveSheet.ChartObjects("Chart 1").Activate
      'Show the dialog box
      Application.Dialogs(xlDialogFormatChart).Show 1
   End Sub 


MORE INFORMATION

The Application.Dialog Show method follows the interactive XLM command (in this case =FORMAT.CHART?(1)). If the XLM command requires one or more arguments, then so does the Visual Basic for Applications method.

For more information about "Built-In Dialog Box Argument Lists," click the Index tab in Help, type the following text

Built-In Dialog


and then double-click the selected text to go to the "Built-In Dialog Box Argument Lists" topic.


REFERENCES

"Visual Basic User's Guide," version 5.0, Chapter 11, "Controls and Dialog Boxes," page 234

Additional query words: 5.00c

Keywords : kbprg
Version : WINDOWS:5.0,5.0c,7.0; winnt:5.0
Platform : WINDOWS winnt
Issue type :


Last Reviewed: October 19, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.