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: Recorded Macro Contains DrawingObjects Method


View products that this article applies to.

This article was previously published under Q213526

↑ Back to the top


Symptoms

When you record a Microsoft Visual Basic for Applications macro in Microsoft Excel, the hidden DrawingObjects method is recorded in your macro. Specifically, the following line of code is recorded:
   ActiveSheet.DrawingObjects.Select
				

↑ Back to the top


Cause

This behavior occurs when you record a macro in which you select all of the objects in a worksheet.

Although the DrawingObjects method is hidden in Microsoft Excel 97 and later, it provides the same functionality that it does in versions of Microsoft Excel earlier than Excel 97. If you select all the objects in a worksheet while recording a macro, the recorded code uses the DrawingObjects method instead of the Shapes collection. This behavior is by design of Microsoft Excel.

↑ Back to the top


Workaround

If you prefer to use the Shapes collection instead of the DrawingObjects method, replace the line of recorded code. To do this, search the macro for the following code:
   ActiveSheet.DrawingObjects.Select
				

Replace this code with the following code:
   ActiveSheet.Shapes.SelectAll
				

Both lines of code are functionally identical.

↑ Back to the top


More information

In Microsoft Excel, you can select all the drawing objects in a worksheet by following these steps:
  1. On the Edit menu, click Go To.
  2. In the Go To dialog box, click Special.
  3. In the Go To Special dialog box, click Objects, and then click OK.
All of the objects in the worksheet are selected.

If you perform these steps while recording a Visual Basic macro, the recorded code uses the older DrawingObjects method instead of the newer Shapes collection. This does not present a problem when you run the recorded code.

↑ Back to the top


Keywords: KB213526, kbpending, kbdtacode, kbbug

↑ Back to the top

Article Info
Article ID : 213526
Revision : 5
Created on : 10/10/2006
Published on : 10/10/2006
Exists online : False
Views : 251