+ Reply to Thread
Results 1 to 6 of 6

Error when setting plotarea width property of a chart in VBA

  1. #1
    Forum Contributor
    Join Date
    01-18-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    127

    Error when setting plotarea width property of a chart in VBA

    Hi all,
    I'm getting an error message when trying to set the width and left properties of my chart in VBA. I want to fix these properties without selecting the chart first. My code is

    Please Login or Register  to view this content.
    But this gives me a Object Doesn't Support This Property Or Method error.
    I've also tried:

    Please Login or Register  to view this content.
    but to no avail. Can anyone help me with the full qualifying way of doing this?

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Error when setting plotarea width property of a chart in VBA

    Hi, your second bit of code is the correct syntax:

    Please Login or Register  to view this content.
    I would assume that kpiws is not a valid reference to a worksheet? Can you post your full code? Note - the maximum width you can set to the chart plotarea is the width of the chartobject.

  3. #3
    Forum Contributor
    Join Date
    01-18-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    127

    Re: Error when setting plotarea width property of a chart in VBA

    Hi thanks for getting back.

    It's set fine I think. owb is set as a Public variable as workbook
    Full code is:

    Please Login or Register  to view this content.
    I adapted the code from recording a macro in my personal workbook. It came up with the following:

    Please Login or Register  to view this content.
    This is actually reducing the size of the chart width from what it is loaded as, so it shouldn't be a problem. I just wanted to perform the same action without needing to select the chart first. But how do I do that?

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Error when setting plotarea width property of a chart in VBA

    Hi - please can you upload an example workbook for which this code is throwing up the error you mention:
    Please Login or Register  to view this content.
    Inserting .chart is the usual solution.

  5. #5
    Forum Contributor
    Join Date
    01-18-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    127

    Re: Error when setting plotarea width property of a chart in VBA

    Unfortunately it still brings up an error using that code: Method 'width' of object 'plotarea' failed.

    I managed to get it working by using the following code:
    Please Login or Register  to view this content.
    But this has run me into another problem - it misplaced the graph completely on the left of the spreadsheet. Seems like the recorded values don't translate the same when at runtime. So i pasted the whole macro recorded code above in its place to see what that would do, even though I didn't quite want it done that way. The same thing happened - i.e. the whole graph is moved to the left of the spreadsheet.

  6. #6
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Error when setting plotarea width property of a chart in VBA

    You are assigning it to the .left property of the chartobject, not the plot area which is why it moves the whole sheet.

    Please upload a workbook.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Method 'Width' of object 'PlotArea' failed?
    By jmadsen in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-14-2016, 11:47 PM
  2. Problem with .PlotArea.Width
    By BRKJ in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-09-2011, 11:53 AM
  3. Excel 2007 : Chart.PlotArea.Width does not work
    By Gabor in forum Excel General
    Replies: 7
    Last Post: 05-23-2009, 06:19 AM
  4. trouble setting plotarea size
    By Albert in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-17-2006, 05:45 PM
  5. [SOLVED] Error setting shape text property
    By Sarge in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 01-10-2006, 11:35 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1