Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
jintao
 
Posts: n/a
Default Inexact? InsideTop and InsideLeft Method of PlotArea (Excel 97)


I am having a problem of using InsideLeft and InsideTop method of
a PlotArea of a PlotChart. It doesn't give out an exact value, always
offset by a bit. Fairly annoying, is it a bug of Excel 97?


--
jintao
------------------------------------------------------------------------
jintao's Profile: http://www.excelforum.com/member.php...o&userid=25395
View this thread: http://www.excelforum.com/showthread...hreadid=388667

  #2   Report Post  
Jon Peltier
 
Posts: n/a
Default

It might be the difficulty of measuring in points a rectangle that's internally
defined by the pixel density of the screen.

How do you mean it's offset? Offset from what? The plot area dimensions are measured
as the distances from the Chart Area top and left edges, which are offset from the
chart object's top and left edges.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______

jintao wrote:

I am having a problem of using InsideLeft and InsideTop method of
a PlotArea of a PlotChart. It doesn't give out an exact value, always
offset by a bit. Fairly annoying, is it a bug of Excel 97?



  #3   Report Post  
jintao
 
Posts: n/a
Default


:( Here is my code to draw a diagonal line across the plotarea of the
chart, it does work but the Line does not align with the plotarea
exactly. Quite annoying


Sub DrawDiag()
With Worksheets(1)

'Get Chart Size
ChartSizeX = .ChartObjects(1).Chart.PlotArea.InsideWidth
ChartSizeY = .ChartObjects(1).Chart.PlotArea.InsideHeight

'Get Chart Positiion
ChartOffsetX = .ChartObjects(1).Left
ChartOffsetY = .ChartObjects(1).Top
PlotAreaOffsetX = .ChartObjects(1).Chart.PlotArea.InsideLeft
PlotAreaOffsetY = .ChartObjects(1).Chart.PlotArea.InsideTop

ChartPosX = ChartOffsetX + PlotAreaOffsetX
ChartPosY = ChartOffsetY + PlotAreaOffsetY

ChartEndX = ChartSizeX + ChartPosX
ChartEndY = ChartSizeY + ChartPosY

With .Shapes.AddLine(ChartPosX, ChartPosY, ChartEndX,
ChartEndY).Line
.Parent.Name = "line"
End With

End With
End Sub


--
jintao
------------------------------------------------------------------------
jintao's Profile: http://www.excelforum.com/member.php...o&userid=25395
View this thread: http://www.excelforum.com/showthread...hreadid=388667

  #4   Report Post  
Jon Peltier
 
Posts: n/a
Default

Couple points:

1. In the VB Editor, select Options from the Tools menu, and on the Editor tab,
check Require Variable Declarations. This puts "Option Explicit" at the top of your
modules, and forces you to declare (Dim) your variables.

2. Your code is adding a line to the worksheet, not to the chart. THis makes
positioning even more difficult. My code below adds the line to the chart within the
chart object, so at least it moves with the chart (but won't resize properly).

Sub DrawDiag()
Dim PlotAreaOffsetX As Single
Dim PlotAreaOffsetY As Single
Dim ChartSizeX As Single
Dim ChartSizeY As Single

With Worksheets(1).ChartObjects(1).Chart

'Get Chart Size
ChartSizeX = .PlotArea.InsideWidth
ChartSizeY = .PlotArea.InsideHeight

'Get Chart Position
PlotAreaOffsetX = .PlotArea.InsideLeft
PlotAreaOffsetY = .PlotArea.InsideTop

'Draw the line
With .Shapes.AddLine(PlotAreaOffsetX, PlotAreaOffsetY, _
PlotAreaOffsetX + ChartSizeX, PlotAreaOffsetY + ChartSizeY)
.Line.Parent.Name = "line"
End With

End With
End Sub

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______


jintao wrote:

:( Here is my code to draw a diagonal line across the plotarea of the
chart, it does work but the Line does not align with the plotarea
exactly. Quite annoying


Sub DrawDiag()
With Worksheets(1)

'Get Chart Size
ChartSizeX = .ChartObjects(1).Chart.PlotArea.InsideWidth
ChartSizeY = .ChartObjects(1).Chart.PlotArea.InsideHeight

'Get Chart Positiion
ChartOffsetX = .ChartObjects(1).Left
ChartOffsetY = .ChartObjects(1).Top
PlotAreaOffsetX = .ChartObjects(1).Chart.PlotArea.InsideLeft
PlotAreaOffsetY = .ChartObjects(1).Chart.PlotArea.InsideTop

ChartPosX = ChartOffsetX + PlotAreaOffsetX
ChartPosY = ChartOffsetY + PlotAreaOffsetY

ChartEndX = ChartSizeX + ChartPosX
ChartEndY = ChartSizeY + ChartPosY

With .Shapes.AddLine(ChartPosX, ChartPosY, ChartEndX,
ChartEndY).Line
.Parent.Name = "line"
End With

End With
End Sub



  #5   Report Post  
jintao
 
Posts: n/a
Default


Thank You Alot!!!!!!


--
jintao
------------------------------------------------------------------------
jintao's Profile: http://www.excelforum.com/member.php...o&userid=25395
View this thread: http://www.excelforum.com/showthread...hreadid=388667

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"