Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    Sep 2002
    Location
    Honolulu, Hawaii, USA
    Posts
    63
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Grabbing that slippery chart object (2003 SP2)

    Aloha,
    If I select an embedded chart, I can check some of its properties in the VB Editor's Immediate window using statements such as

    ?Selection.Left

    But when I try to act upon the selected chart with a similar statement

    Selection.Left=6

    I get a runtime error 438. Why does the same syntax work as a question and not as a command? What exactly is the object that I need to identify, and how do I specify it?

    Mahalo,

    John Jacobson

  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Grabbing that slippery chart object (2003 SP2)

    "Object doesn't support this property or method"

    Most likely the object selected isn't what you think it should be. What does

    Debug.Print Typename(Selection)

    return at that point in the code? Perhaps you could post more of the code?
    -John ... I float in liquid gardens
    UTC -7ąDS

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

    Re: Grabbing that slippery chart object (2003 SP2)

    Try

    ActiveChart.Parent.Left = 6

    The parent of ActiveChart is the Shape that contains the chart.

  4. #4
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Grabbing that slippery chart object (2003 SP2)

    John,
    I would guess that, unless you used Ctrl+click to select the chart, your selection is actually the chartarea, not the chartobject. AFAIK, the ChartArea dimensions are fixed within a chart, hence the fact you cannot resize it. You could use:
    <code>Selection.Parent.Parent.Left = 6</code>
    to set the Left property of the ChartObject.
    HTH
    Regards,
    Rory

    Microsoft MVP - Excel

  5. #5
    Star Lounger
    Join Date
    Sep 2002
    Location
    Honolulu, Hawaii, USA
    Posts
    63
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Grabbing that slippery chart object (2003 SP2)

    Thanks all,

    Rory had it right. The selected object was the ChartArea, and I needed to get to the ChartObject. I was able to use

    Selection.Parent.Parent.Left

    to act upon it. btw JohnBF, there was no 'code', I was simply using the Immediate window to execute some one-line commands.
    Mahalo all,
    John Jacobson

Posting Permissions

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