Knowledge Base |

# Can't Set Property of Outline Class With Object Selected

Article ID: 111310

Article Last Modified on 10/11/2006

APPLIES TO

- Microsoft Excel 95a
- Microsoft Excel 5.0c
- Microsoft Excel 5.0a for Macintosh

This article was previously published under Q111310

## 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. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers 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 requirements. 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 XL

Keywords: kbcode kbprb kbprogramming KB111310