Results 1 to 4 of 4
  1. #1
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    ChartSpace Control (XL 2000)

    Does anyone have a sample UserForm that displays an XY Scatter chart on a ChartSpace control (Microsoft Office Chart 9.0)? TIA --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  2. #2
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: ChartSpace Control (XL 2000)

    Sam,
    I know nothing of this control, but I did find these links that seems to show VBA Code and a zip download with a possible sample file.

    Try it out - if its worth anything!?

    Chart Space Control Link 1
    Chart Space Control Link 2
    Regards,
    Rudi

  3. #3
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: ChartSpace Control (XL 2000)

    Somewhat helpful, but hard to map into VBA space. This MSDN article is also helpful.

    In trying to answer my own question, I created a demo UserForm in Word, added a ChartSpace control called cs, and tried to load data into cs on the form click event. The axes change (incorrectly), but no data is visible. Here is the code. I've also attached the Word doc. I only put it in a Word document so that the names in the object models don't overlap. I also had to use Office 2003: it was all I had on this machine.
    <pre>Option Explicit

    Private Sub UserForm_Click()
    ' Make some sample data
    Dim i As Long, x(1 To 10) As Double, y(1 To 10) As Double
    For i = 1 To 10
    x(i) = i
    y(i) = x(i) ^ (x(i) * 1.3)
    Next i

    ' Construct a chart with the data
    cs.Clear ' Remove existing charts
    Dim cht As OWC10.ChChart
    Set cht = cs.Charts.Add ' Create a chart
    Dim sc As OWC10.ChSeries
    Set sc = cht.SeriesCollection.Add ' Create a series
    cht.Type = chChartTypeScatterLineMarkers 'Set the chart type
    sc.SetData chDimXValues, chDataLiteral, x 'Add the x-categories
    sc.SetData chDimYValues, chDataLiteral, y 'Add the y-values
    End Sub
    </pre>

    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: ChartSpace Control (XL 2000)

    The problem seems to be in the declaration of x and y as arrays of Double. If you declare them as Variant (or omit the type, Variant is the default), it works:

    Dim i As Long, x(1 To 10), y(1 To 10)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •