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.

You cannot record new shapes, shape formatting, and shape effects by using the macro recorder in Excel 2007


View products that this article applies to.

Symptoms

In Microsoft Office Excel 2007, you cannot record new shapes, shape formatting, and shape effects by using the macro recorder. For example, you cannot record chart elements, fill-in colors, line styles, and line effects by using the macro recorder.

You can format labels and position titles that you can record by using the macro recorder in Excel 2007.

Note In Microsoft Office Excel 2003, you can record the formatting of all chart elements by using the macro recorder.

↑ Back to the top


Workaround

To work around this behavior, use Microsoft Visual Basic for Applications (VBA) code to format the shapes.

Note In Visual Basic Editor, click Object Browser on the View menu to find the correct objects, methods, and properties that are used in VBA code.

The following example illustrates how to use VBA code to format chart elements:
  1. Start Excel 2007.
  2. Add the following data to Sheet1:
    A1 A
    A2 2
    B1 B
    B2 2
  3. Select A1: B2.
  4. On the Insert tab, click Line in the Charts group, and then click Line. Notice that the chart is displayed in Sheet1.
  5. On the Developer tab, click Visual Basic in the Code group to start Visual Basic Editor.
  6. Add the following code example to format chart elements.
    Sub ProgramChartObjects()
        Dim cht
        Set cht = ActiveSheet.ChartObjects(1)
        cht.Activate
        ActiveChart.ApplyLayout (10)
           
        cht.ShapeRange.Height = 200
        cht.ShapeRange.Item(1).Glow.Color.SchemeColor = 8
        cht.ShapeRange.Item(1).Glow.Radius = 20 'Max is 20
        cht.ShapeRange.Item(1).Glow.Color.RGB = RGB(255, 0, 0)
        cht.ShapeRange.Item(1).Glow.Color.TintAndShade = 0.5
        cht.ShapeRange.Item(1).Shadow.Style = msoShadowStyleInnerShadow
        cht.ShapeRange.Item(1).Shadow.Visible = True
        cht.ShapeRange.Item(1).Shadow.Blur = 21
        cht.ShapeRange.Item(1).Shadow.ForeColor.RGB = RGB(0, 255, 0)
        cht.ShapeRange.Item(1).Shadow.Transparency = 0.45
     
       'Stop
    End Sub
    
  7. Press F5. Notice that the chart in Sheet1 is formatted.
o see all the declared variables and values in the current procedure, follow these steps:
  1. In Visual Basic Editor, click Locals Window on the View menu.
  2. Uncomment "Stop" in the code example.
  3. Press F5.

↑ Back to the top


Status

This behavior is by design.

↑ Back to the top


More information

In Excel 2007, the new ChartFormat object provides access to OfficeArt formatting for chart elements. However, the properties of the ChartFormat object are read-only. Therefore, they cannot be recorded.

↑ Back to the top


Keywords: KB937620, kbexpertisebeginner, kbtshoot, kbprb

↑ Back to the top

Article Info
Article ID : 937620
Revision : 1
Created on : 6/4/2007
Published on : 6/4/2007
Exists online : False
Views : 265