Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

This article was previously published under Q212177

↑ Back to the top


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.

↑ Back to the top


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.

↑ Back to the top


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: For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:
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.

↑ Back to the top


Status

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

↑ Back to the top


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.

↑ Back to the top


References

For more information about using the built-in dialog boxes, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type built-in dialog box argument list in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

↑ Back to the top


Keywords: KB212177, kbprogramming, kbpending, kberrmsg, kbcode, kbbug

↑ Back to the top

Article Info
Article ID : 212177
Revision : 6
Created on : 11/23/2006
Published on : 11/23/2006
Exists online : False
Views : 328