XL97: Macro Error Using Show Method with AutoShape SelectedLast reviewed: July 2, 1997Article ID: Q166143 |
The information in this article applies to:
SYMPTOMSIn Microsoft Excel 97, if you run a Visual Basic for Applications macro that attempts to display the Format AutoShape dialog box, you may receive the following error message:
Run-time error '1004': Show method of Dialog class failedOr, the Format AutoShape dialog box may simply fail to appear, and you do not receive an error message. The same macro works correctly in earlier versions of Microsoft Excel, and works occasionally in Microsoft Excel 97.
CAUSEYou may receive the aforementioned error message if both of the following are true:
WORKAROUNDMicrosoft 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. The xlDialogPatterns dialog box is not available for use with new drawing objects and AutoShapes in Microsoft Excel 97. However, it may be possible in some cases to display the Format AutoShape dialog box by using a line of code similar to the following:
Sub Test1() SendKeys "^1", True End SubIf the drawing object or AutoShape is selected when this line of code is executed, the Format AutoShape dialog box will be displayed, and you can format the AutoShape. When you click OK or Cancel, the macro will continue. If you have not renamed any of your drawing objects or AutoShapes, you can use code similar to the following to display the correct dialog box:
Sub Test2() 'If the name of the drawing object begins with "AutoShape", then... If Left(Selection.Name, 9) = "AutoShape" Then '...use SendKeys to display the dialog box. SendKeys "^1", True 'Otherwise, use the traditional method. Else Application.Dialogs(xlDialogPatterns).Show End If End SubNote that these methods may not always work, since it is not always possible to guarantee that the sent keys will produce the desired result. Note also that the SendKeys method is not available in Microsoft Excel for the Macintosh.
STATUSMicrosoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
MORE INFORMATIONAutoShapes are a group of ready-made shapes that include such basic shapes as rectangles and circles, plus a variety of lines and connectors, block arrows, flowchart symbols, stars and banners, and callouts. The AutoShapes that may cause the problem described above are most of those found on the AutoShapes menu of the Drawing toolbar. This includes AutoShapes from the following submenus:
Connectors Basic Shapes Block Arrows Flowchart Stars and Banners CalloutsNOTE: Not all of the Basic Shapes generate the error message.
REFERENCESFor more information about using the Built-in Dialogs, click the Office Assistant, type "built-in dialogs" (without quotation marks), click Search, and then click to view the "Built-In Dialog Box Argument List" topic. |
Keywords : kbcode kberrmsg kbprg xlvbainfo
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |