• Grabbing that slippery chart object (2003 SP2)

    Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Grabbing that slippery chart object (2003 SP2)

    Author
    Topic
    #436080

    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

    Viewing 2 reply threads
    Author
    Replies
    • #1032710

      “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?

    • #1032717

      Try

      ActiveChart.Parent.Left = 6

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

    • #1032741

      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:
      Selection.Parent.Parent.Left = 6
      to set the Left property of the ChartObject.
      HTH

      • #1033403

        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

    Viewing 2 reply threads
    Reply To: Grabbing that slippery chart object (2003 SP2)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: