+ Reply to Thread
Results 1 to 6 of 6

How to find the location (in pixels) of a chart in macros?

  1. #1
    Registered User
    Join Date
    01-19-2011
    Location
    NYC
    MS-Off Ver
    Excel 2003
    Posts
    5

    Exclamation How to find the location (in pixels) of a chart in macros?

    I'm trying to find the location of X axis in the chart. Is there a method/property to find it?

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: How to find the location (in pixels) of a chart in macros?

    You can use properties of the chart object but the dimensions will be in points.

    Why do you need to know?
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    01-19-2011
    Location
    NYC
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: How to find the location (in pixels) of a chart in macros?

    I need to place a Data Label for one column just below the X axis if that appears above the X axis. I have to find out somehow whether the label is above the X axis, If yes move it below X axis, if not ignore it. This has to be done programmatically in VBA.

    I’m having this problem when the column value (-ve) is too small compare to other columns and column is not visible and data label somehow appears above X axis instead of below. I tried DataLabel.Position = xlLabelPositionBelow in my macro, but it doesn’t work. So I’m thinking if I find the position of X axis I can move that label few pixels below X axis position

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: How to find the location (in pixels) of a chart in macros?

    First did you see my reply to your other post on the subject which fixes the problem?

    You do not need to know any pixel sizes. Instead you can use the point values provided by the objects.
    Your main issue is working out the axis position as the Left property returns the same value as the inside left of plot area.

  5. #5
    Registered User
    Join Date
    01-19-2011
    Location
    NYC
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: How to find the location (in pixels) of a chart in macros?

    Hi Andy, Thanks for your reply and help. I saw your reply on the other post, but I couldn’t set the minimum scale value to -15 because it is always calculated based on the highest –ve value (in my case it is -5) and users want it that way only. Later I found that whenever we use any Macro to make any changes to the data label it causes that problem, so it is resolved when I removed the macro code.

    The one I’m having problem now is a Column chart (I have attached the image) and I don’t have any macros, but still –ve value shows up on the +ve side.

    Thanks
    Attached Images Attached Images

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: How to find the location (in pixels) of a chart in macros?

    Given you example picture it would appear that a Line series with data labels displayed in either the Above or Below position behave themselves.

    So you could code it so another temporary series is added and use the line series data labels to check and if requried position the column data labels.

    If not you will need to do as I suggested and that is calculate the position of the Axis line and then check the Top position of the data label

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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