O
Oleg
I need to find sizes and positions of rectangles that bound every text
fragment (word) and shape (picture) in MS Word Document (page formatting is
set).
I'm trying to do it by manipulating Rectangles property of Pages
(_Document.ActiveWindow.ActivePane.Pages) object :
object missing = Type.Missing;
object fileName = @"c:\1.rtf";
object dontConfirmConversions = false;
object openReadWrite = true;
object nonVisible = false;
Word._Application wapp = new Microsoft.Office.Interop.Word.Application();
Word._Document doc = wapp.Documents.Open( ref fileName, ref
dontConfirmConversions,
ref openReadWrite, ref missing, ref missing, ref missing, ref missing, ref
missing,
ref missing, ref missing, ref missing, ref nonVisible, ref missing, ref
missing,
ref missing, ref missing );
Word.Pages pages = doc.ActiveWindow.ActivePane.Pages;
using ( StreamWriter sw = new StreamWriter( "TestFile.txt" ) ) {
foreach ( Word.Page p in pages ) {
Word.Rectangles rects = p.Rectangles;
foreach ( Word.Rectangle r in rects ) {
sw.WriteLine( " Width:" + r.Width + " Height: " + r.Height );
}
}
}
The output of such fragment of code must be file TestFile.txt, which
contains lines with bounding rectangles sizes.
But I have only one record in result. ( for example, Width:312 Height: 728).
This question is for real professional, which I'm not.
Please, help me.
fragment (word) and shape (picture) in MS Word Document (page formatting is
set).
I'm trying to do it by manipulating Rectangles property of Pages
(_Document.ActiveWindow.ActivePane.Pages) object :
object missing = Type.Missing;
object fileName = @"c:\1.rtf";
object dontConfirmConversions = false;
object openReadWrite = true;
object nonVisible = false;
Word._Application wapp = new Microsoft.Office.Interop.Word.Application();
Word._Document doc = wapp.Documents.Open( ref fileName, ref
dontConfirmConversions,
ref openReadWrite, ref missing, ref missing, ref missing, ref missing, ref
missing,
ref missing, ref missing, ref missing, ref nonVisible, ref missing, ref
missing,
ref missing, ref missing );
Word.Pages pages = doc.ActiveWindow.ActivePane.Pages;
using ( StreamWriter sw = new StreamWriter( "TestFile.txt" ) ) {
foreach ( Word.Page p in pages ) {
Word.Rectangles rects = p.Rectangles;
foreach ( Word.Rectangle r in rects ) {
sw.WriteLine( " Width:" + r.Width + " Height: " + r.Height );
}
}
}
The output of such fragment of code must be file TestFile.txt, which
contains lines with bounding rectangles sizes.
But I have only one record in result. ( for example, Width:312 Height: 728).
This question is for real professional, which I'm not.
Please, help me.