Results 1 to 7 of 7
  1. #1
    5 Star Lounger
    Join Date
    Apr 2003
    Location
    Hampshire, United Kingdom
    Posts
    602
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Can't set MaximumScale of axis (2003)

    I have two charts within a worksheet, and I want to change the scale of one so it matches the scale of the other. Here's what I have:
    <div style="width: 100%; background-color: #FFFFFF;">Function AlignGraphs()
    Dim c1 As Chart, a1 As Axis, c2 As Chart, a2 As Axis
    Set c1 = shtModel.ChartObjects(1).Chart
    Set a1 = c1.Axes(xlValue)
    Set c2 = shtModel.ChartObjects(2).Chart
    Set a2 = c2.Axes(xlValue)</div hiblock> <span style="background-color: #FFFF00; color: #000000; font-weight: bold">a2.MaximumScale = a1.MaximumScale</span hi>
    <div style="width: 100%; background-color: #FFFFFF;">End Function</div hiblock>
    When I run the above, I receive (at the highlighted line):
    <div style="width: 100%; background-color: #FFFFFF;">Run-time error '1004': Unable to set the MaximumScale property of the Axis class</div hiblock>
    I expect I'm missing something obvious, but can't see it. Any ideas?
    Waggers
    If at first you do succeed, you&#39;ve probably missed something.

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

    Re: Can't set MaximumScale of axis (2003)

    Are they the same chart types? In a quick test, your code did what it is supposed to do.

  3. #3
    5 Star Lounger
    Join Date
    Apr 2003
    Location
    Hampshire, United Kingdom
    Posts
    602
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Can't set MaximumScale of axis (2003)

    Yes. they're both bar charts (of the horizontal variety). It's returning the correct value for the first chart, but can't get or set the property for the second.
    Waggers
    If at first you do succeed, you&#39;ve probably missed something.

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

    Re: Can't set MaximumScale of axis (2003)

    Could you post (a stripped down copy of) the workbook?

  5. #5
    5 Star Lounger
    Join Date
    Apr 2003
    Location
    Hampshire, United Kingdom
    Posts
    602
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Can't set MaximumScale of axis (2003)

    Thought you might say that <img src=/S/grin.gif border=0 alt=grin width=15 height=15>. I won't be able to do so until Monday, so I'm afraid I'l' have to leave you in suspense for the weekend.
    Waggers
    If at first you do succeed, you&#39;ve probably missed something.

  6. #6
    5 Star Lounger
    Join Date
    Apr 2003
    Location
    Hampshire, United Kingdom
    Posts
    602
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Can't set MaximumScale of axis (2003)

    Ok, in creating a stripped down version I think I've located the problem. As usual, I tried to make things easier in my original post by not telling the full story, and neglected to mention an important detail: I'm trying to overlay the two charts, so I've removed the axes from the second one. I expect I'll need to restore the value axis in order to change the chart's scale, and then remove it again afterwards. I'll give that a go...
    Waggers
    If at first you do succeed, you&#39;ve probably missed something.

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

    Re: Can't set MaximumScale of axis (2003)

    Sounds reasonable - if the value axis has been removed, you can't set its properties.

Posting Permissions

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