XL97: Macro Error Using Show Method with AutoShape Selected (166143)
The information in this article applies to:
- Microsoft Excel 97 for Windows
This article was previously published under Q166143 SYMPTOMS
In 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 failed
Or, 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.
CAUSE
You may receive the aforementioned error message if both of the following
are true:
WORKAROUND
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 professionals
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 Sub
If 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 Sub
Note 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.
STATUS
Microsoft has confirmed this to be a problem in the Microsoft products
listed at the beginning of this article.
REFERENCES
For more information about using the Built-in Dialogs, click the Office
Assistant, type built-in dialogs, click
Search, and then click to view the "Built-In Dialog Box Argument List"
topic.
Modification Type: | Major | Last Reviewed: | 10/22/2000 |
---|
Keywords: | kbbug kbcode kberrmsg kbProgramming KB166143 |
---|
|