Weird chart sizing observation

I'm not sure if the observation is weird, or the actual chart sizing is. I think this is a bug, but I'm curious if others see similar behavior. This is an Office 2007 thing (at least, I haven't tested it in other versions…) Here's the repro steps:

  • Make a chart and select it
  • In the VBE, find out the width. I just did the following in the immediate window:

    ? selection.width

  • It came back with 400. All good
  • Set the width to something (again in the immediate window):

    Selection.width = 245

  • Now, check the width again:

    ? selection.width

  • It comes back with 250

This strikes me as a little strange. I would have thought that the width would be the same as what I set it to. No matter the number given, it always seems to come back with a width that is 5 pixels larger than what I set it to.

The height and left properties do not seem to suffer this issue, only the width that I've encountered so far…

Anyone else get similar behavior?



3 thoughts on “Weird chart sizing observation

  1. Correction... Left also seems to be off. Specifically, if you retrieve the Left property of a cell and then set the left property of the chart to match, the chart shows up about 5 pixels right of the left cell border. 5.64721679687 pixels, to be precise.


  2. Could it be something to do with that extr border that is shown when you select the chart?

    If you do

    activesheet.shapes("Chart 1").width = 310


    ?activesheet.shapes("Chart 1").width

    you get 310!

  3. This is bizarre... I can't repro this, but I still can see an issue here.

    Setting the Left of the shape to be equal to the Left of the cell, and also the Width to the same numbers results in a chart that is shifted the 5.x pixels to the right. As Bob mentioned, it has everything to do with the width of the frame that is placed around the chart when you select it...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Latest Posts