Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Line on Excel chart not quite horizontal

Status
Not open for further replies.

RobBroekhuis

Technical User
Oct 15, 2001
1,971
US
This is puzzling the heck out of me: I'm trying to put a horizontal line on an excel chart, using the following code:

ActiveChart.Shapes.AddLine(LegX + 6, LineY, LegX + 26, LineY).Select

LegX and LineY are declared single (as per the AddLine parameter definition). For some reason, this code always puts a not-quite-horizontal line on my chart, with a .top that is 0.5 points smaller than my LineY, and a .height of 0.75. Somehow, the point-to-pixel conversion for the starting point seems to be different from that for the end point. What can I do to prevent this?
Rob
[flowerface]
 
I tried to reproduce your symptom in Excel 97 but was unable to.

I did notice along the way that there is a Rotation property in the FormatAutoShape dialog (Size tab) and that there is a Set AutoShape Defaults menu choice on the pop-up. This would seem to imply that it is possible to set a rotation of a couple of degrees that would always be there, but I couldn't make it sticky.

I'll be watching this thread with interest.
 
I played with this some more, and found the following interesting information: when I straighten out the line manually and record my actions as a macro, Excel actually generates a macro that sets the width and height properties (the height to 0.30), and then does a shaperange.flip operation. I've noticed before that the flip bit gets recorded - probably necessary because Excel can't otherwise specify a diagonal-up line (instead of X1,Y1,X2,Y2, Excel uses X1,Y1,Width,Height to specify the shape, where the latter two cannot be negative - not a particularly useful way to define a line...)
Still trying to figure this out.
Rob
[flowerface]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top