I am trying to get the absolute position of shape (top and left) inside a page.
The shape is inside a table cell.
objShape.Top return 0
objShape.Left return 0
the objShape.RelativeHorizontalPosition value is “column”
In the Word object model i can do it using this code:
top = objShape.Range.Information[WdInformation.wdHorizontalPositionRelativeToPage];
left = objShape.Range.Information[WdInformation.wdVerticalPositionRelativeToPage];
Document doc = new Document(@"C:\Temp\in.docx");
LayoutCollector collector = new LayoutCollector(doc);
LayoutEnumerator enumerator = new LayoutEnumerator(doc);
// Get shape from the document.
Shape shape = (Shape)doc.GetChild(NodeType.Shape, 0, true);
// Make sure shape is in the main body (LayoutCollector and LayoutEnumerator work only with nodes in the main body)
if (shape.GetAncestor(NodeType.HeaderFooter) == null)
{
enumerator.Current = collector.GetEntity(shape);
Console.WriteLine(enumerator.Rectangle);
}