tcalbaz
asked on
Excel 2002: How do I use VBA to set the area size of my chart to 600 width 300 height?
I just upgraded my Office 97 to 2002. I can't seem to set the absolute width and height of my chart to a 600 pixel width and a 300 pixel height on the activesheet. Does anybody have a technique for this?
Many thanks,
Many thanks,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Well Done!
Thank You Sebastienm!
Ted
Thank You Sebastienm!
Ted
Thank you for the points, Ted.
Regards,
Sebastien
Regards,
Sebastien
several ways...
1. you can go through the Shape object:
ActiveSheet.Shapes("Chart 1").width = 600
ActiveSheet.Shapes("Chart 1").height = 300
2. or the ChartObjects()
activesheet.chartobjects(1
activesheet.chartobjects(1
however, the units are in points, not pixels.
You can transform points to pixels, by using the
PointsToScreenPixelsX
PointsToScreenPixelsY
functions of the Window object, eg:
ActiveSheet.Shapes("Chart 1").Width = 600 / ActiveWindow.PointsToScree
ActiveSheet.Shapes("Chart 1").Top = 300 / ActiveWindow.PointsToScree
or by applying the function of the Application.Windows(1).
Just make sure a window is there when you run it.
Regards,
Sebastien