PRB: "Object Required: 'ChartSpace1.Border'" Run-Time Error When You Set the ChartSpace Border Properties for Office XP Chart Component (318050)



The information in this article applies to:

  • Microsoft Internet Explorer (Programming) 6.0
  • Microsoft Office Chart Component 9.0
  • Microsoft Office 2003 Web Components
  • Microsoft Office XP Web Components

This article was previously published under Q318050

SYMPTOMS

When you run script that accesses the Border property for a Microsoft Office Chart component in Microsoft Internet Explorer 6.0, you receive the following run-time error:
Object Required: 'ChartSpace1.Border'

CAUSE

Internet Explorer 6.0 has added support for a Border property on the HTMLObjectElement. This change may create a conflict.

When you access an <OBJECT> on a Web page by its ID in script, you are referring to the wrapper that is around the object in Internet Explorer. When you reference the <object>.Border property, Internet Explorer first determines if the wrapper supports the property. If the wrapper does not support the property, Internet Explorer then passes the property call to the object itself.

Internet Explorer 6.0 now supports a Border property for the wrapper of a chart. Therefore, a call to Chartspace1.Border calls the Border property of the wrapper. It does not call the Border property for the ChartSpace, as you might expect.

RESOLUTION

To access the Border property for the chart and not for the wrapper, use the Object property for the ChartSpace, as follows:
Chartspace1.Object.Border.Color = ChartSpace1.Constants.chColorNone
				

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Save the following file as Border.htm.
    <html>
    
    <body>
    <p><object classid="clsid:<Class Identifier for Chart Control>" id="ChartSpace1"></object>
    </p><Button id=Btn1>Give Error</Button>
    </p><Button id=Btn2>Change Border</Button>
    </body>
    
    <script language = "VBScript">
    
    Function Btn1_OnClick()
       Chartspace1.Border.Color = ChartSpace1.Constants.chColorNone
    End Function
    
    Function Btn2_OnClick()
       Chartspace1.Object.Border.Color = ChartSpace1.Constants.chColorNone
    End Function
    
    </script>
    
    </html>
    					
    Note Replace the <Class Identifier of Chart Control> in the above code with the Class ID of the chart control being used.

    For Microsoft Office Chart 10.0
    002E556-0000-0000-C000-000000000046

    For Microsoft Office Chart 11.0
    0002E556-0000-0000-C000-000000000046
  2. Start Internet Explorer, and then locate Border.htm.
  3. Click Give Error. You receive a run-time error, and the ChartSpace border remains unchanged.
  4. Press F5 to refresh the page.
  5. Click Change Border. The color of the ChartSpace border changes as expected.

REFERENCES

For more information about programming Microsoft Office Web Components, visit the following page on the Microsoft Developer Network (MSDN) Web site:

Microsoft Office Development with Visual Studio
http://msdn.microsoft.com/library/default.asp?URL=/library/techart/VSOfficeDev.htm

Modification Type:MajorLast Reviewed:9/26/2003
Keywords:kbOfficeWebChart kbprb KB318050