Microsoft KB Archive/212177

= XL2000: Error Message When You Use Macro to Show Format AutoShape Dialog Box =

Article ID: 212177

Article Last Modified on 11/23/2006

-

APPLIES TO


 * Microsoft Excel 2000 Standard Edition

-



This article was previously published under Q212177





SYMPTOMS
In Microsoft Excel 2000, if you run a Microsoft Visual Basic for Applications macro that attempts to display the Format AutoShape dialog box, the Format AutoShape dialog box may not appear. You may receive the following error message:

Run-time error '1004':

Show method of Dialog class failed

The same macro works correctly in versions of Microsoft Excel earlier than Microsoft Excel 97, and it works intermittently in Microsoft Excel 2000.



CAUSE
You may receive the error message if both of the following conditions are true:   Your macro contains a line of code similar to either of the following: Application.Dialogs(xlDialogPatterns).Show

-or- Application.ExecuteExcel4Macro ("PATTERNS?") -and-  An AutoShape is selected when one of the preceding lines of code is run.



WORKAROUND
Microsoft provides programming examples 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 article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please visit the following Microsoft Web site:

https://partner.microsoft.com/global/30000104

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:

http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS

The xlDialogPatterns dialog box is not available for use with new drawing objects and AutoShapes in Excel 2000. However, it may be possible in some cases to display the Format AutoShape dialog box by using code similar to the following: Sub Test1 SendKeys "^1", True End Sub If the drawing object or AutoShape is selected when this 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 Sub NOTE: These methods may not always work, because it is not always possible to guarantee that the sent keys produce the intended result. Note also that the SendKeys method is not available in Microsoft Excel for Mac.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.



MORE INFORMATION
AutoShapes 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 in this article are most of those found on the AutoShapes menu of the Drawing toolbar. This includes AutoShapes from the following menus:
 * Connectors
 * Basic Shapes
 * Block Arrows
 * Flowchart
 * Stars and Banners
 * Callouts

NOTE: Not all of the Basic Shapes result in the behavior described in the "Symptoms" section of this article.

