I have this piece of c# code in my Excel 2003 add-in:
var leafPoint = m_worksheet.Shapes.Item("aPoint").Duplicate();
leafPoint.Name = "Shape" + (m_shapesNameIndex++).ToString();
leafPoint.OnAction = m_worksheet.CodeName + ".PointClicked";
leafPoint.AlternativeText =
string.Format("Correlation Value: {0}",
item.PointData.Correlation.ToString("0.0000;-0.0000"));
leafPoint.Top = item.LeftChildNode.Top +
((item.RightChildNode.Top - item.LeftChildNode.Top) / 2) +
(leafPoint.Height / 2);
When I run it in Excel 2003, it works perfectly. However, when I run it in Excel 2007, the shape's Top value is off... It always ends up a few pixels above the intended location!
When I looked at the logs, in Excel 2003 the shapes were consistently placed in the correct position, but in Excel 2007, when the code attempts to place the shape's Top position, Excel 2007 seems to be overriding the value for some reason (I think).
For instance, in one case the leafPoint.Top
value resolved to 206.25
. In Excel 2003, that was indeed the result. However, in Excel 2007, this value ends up becoming 204.2954
...
Does anyone have some insight into this issue?