Microsoft KB Archive/256627

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 12:35, 21 July 2020 by X010 (talk | contribs) (Text replacement - "&" to "&")

Article ID: 256627

Article Last Modified on 8/23/2005


  • Microsoft Office Web Components
  • Microsoft Office Chart Component 9.0
  • Microsoft Visual Basic, Scripting Edition 5.0

This article was previously published under Q256627


When you use the Office Chart component, the Minimum and Maximum properties of a WCScaling object return incorrect values when called during the onLoad event of a Web page in Internet Explorer. These properties might return incorrect values such as zero or a number that is very small.


With Internet Explorer, there is no guarantee that that all controls on a Web page have an associated window until the Web page finishes loading. Therefore, the Minimum and Maximum properties for a WCScaling object may be uninitialized during the window's onLoad event and attempts to retrieve the Minimum and Maximum properties could result in inconsistent values.


To work around this problem, retrieve the Minimum or Maximum property for a WCScaling object after Internet Explorer has associated a window with the Chart component. If you want to retrieve these properties when your Web page loads, use the window's setTimeout method in the onLoad event to allow the window to finish loading. This work around is illustrated in the "More Information" section.


The following steps illustrate how to reproduce the behavior of the Maximum property when called from the onLoad event. The script creates three charts at run-time and then displays the value returned from the Maximum property in the title of each chart.

Steps to Reproduce Behavior

  1. Use a text editor, such as Notepad, and create a text file that contains the following:

    <OBJECT id=ChartSpace1 classid=CLSID:0002E500-0000-0000-C000-000000000046></OBJECT>
    <OBJECT id=ChartSpace2 classid=CLSID:0002E500-0000-0000-C000-000000000046></OBJECT>
    <OBJECT id=ChartSpace3 classid=CLSID:0002E500-0000-0000-C000-000000000046></OBJECT>
    <SCRIPT Language=VBScript>
    Dim c
    Function Window_OnLoad()
       Set c = ChartSpace1.Constants
    End Function
    Sub CreateCharts()
       Dim i
       Dim oCSpace, oChart
       'Add data to each of the three chartspace objects
       For i=1 to 3
          Set oCSpace = document.all.item("Chartspace" & i)
          Set oChart = oCSpace.Charts.Add
          With oChart.SeriesCollection.Add
             .SetData c.chDimCategories, c.chDataLiteral, _
             .SetData c.chDimValues, c.chDataLiteral, _
                      Array(Rnd()*10, Rnd()*10, Rnd()*10)
          End With
    End Sub
    Sub GetMax()
       Dim i
       Dim oCSpace
       'Display the maximum of the value axis for each chart in the chart title
       For i=1 to 3
          Set oCSpace = document.all.item("Chartspace" & i)
          oCSpace.Charts(0).Title.Caption = "Max = " & _
    End Sub
  2. Save the text file as ChartMax.htm.
  3. Start Internet Explorer and browse to ChartMax.htm.

    RESULTS: The maximum value that is displayed in the Charts' titles may not be correct. The titles for one or more of the charts may indicate a maximum for the value axis that is 0 or a very small number.

To workaround the problem in the sample code, you could call the GetMax function, by using the window's setTimeout method so that Internet Explorer can complete the loading of the window before you retrieve the Maximum property of the value axis. To use the workaround, replace this line in the Window_onLoad event:



window.setTimeout "GetMax", 200, "VBScript"


NOTE: Because this is a timing related issue, you may have to adjust the timeout so that you get the right behavior.


Programming Microsoft Office 2000 Web Components by Dave Stearns, ISBN 0-7356-0794-X, Chapter 6 "Dynamic and Real-Time Charting"

For more information on the Office Web Components, please visit the following support site:

For sample code that demonstrates solutions using the Office 2000 Web Components with VBScript and ASP, see the following article in the Microsoft Knowledge Base:

258187 OWebComp.exe Contains Scripting Samples for the Office Web Components

Additional query words: normalize normalization axes scaling maximum minimum max min

Keywords: kbofficewebchart kbprb KB256627