XL: Can't Set Property of Outline Class With Object Selected

ID: Q111310

The information in this article applies to:

SYMPTOMS

In Microsoft Excel, you may receive the following error message when you run a Microsoft Visual Basic for Applications procedure that changes the property of an Outline object

   Run-time error '1005'

   Unable to set the <property name> property of the Outline class

where <property name> is the property of the Outline class you are changing in the procedure.

CAUSE

Some of the commands you use in a Visual Basic procedure are selection dependent, even when you specify the object name. The above error message appears if you run a procedure to change the property of an Outline when a drawing object or chart object is selected on a worksheet. You can see this visually if you select a drawing object on a worksheet and then choose Group And Outline from the Data menu. Note that the options on the Group And Outline menu are unavailable.

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 the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

   http://www.microsoft.com/support/supportnet/refguide/

To avoid receiving an error message in a Visual Basic procedure with a command that is selection dependent, make sure your procedure makes the proper selection on the workbook. For example, to change a property of the Outline object without receiving an error message, first make sure that a drawing object or chart object is not selected by selecting a cell on the worksheet, as in the following example.

   Sub Outline_Settings()
      ' Select first cell on worksheet
      Range("A1").Select
      ' Select outline settings
      With ActiveSheet.Outline
         ' Clear AutomaticStyles option
         .AutomaticStyles = False
         ' Select Summary Columns To Right of Detail option
         .SummaryColumn = xlRight
      End With
   End Sub

Additional query words: 5.00
Keywords          : kbcode kbprg PgmOthr 
Version           : WINDOWS:5.0,5.0c,7.0,7.0a; MACINTOSH:5.0,5.0a
Platform          : MACINTOSH WINDOWS
Issue type        : kbprb

Last Reviewed: May 17, 1999