A
Ahmed Bedeer
Dear All,
I'm working on a project where I need to extract text information from some
word documents. I need to know each character(range)'s page number, line
number and text-column number.
I use Microsoft Office Interop for Word assembly in C#.
I could find the page number, and line number easily using the
range.get_Information() method, but I could not find the information of
text-column number.
Note: I mean the text-column NOT the column number in a table.
and here is a portion of the code:
//
// After the document is opened using app.Documents.Open()
//
foreach (Microsoft.Office.Interop.Word.Range range in document.Words)
{
string text = range.Text;
lineNo =
(int)range.get_Information(Microsoft.Office.Interop.Word.WdInformation.wdFirstCharacterLineNumber);
pageNo =
(int)range.get_Information(Microsoft.Office.Interop.Word.WdInformation.wdActiveEndPageNumber);
float lineY =
(float)range.Characters.Last.get_Information(Microsoft.Office.Interop.Word.WdInformation.wdVerticalPositionRelativeToPage);
float wordX =
(float)range.get_Information(Microsoft.Office.Interop.Word.WdInformation.wdHorizontalPositionRelativeToPage);
//.. Here I need to know the text-column number of the current range.
//
}
please help,
Thanks in advance
I'm working on a project where I need to extract text information from some
word documents. I need to know each character(range)'s page number, line
number and text-column number.
I use Microsoft Office Interop for Word assembly in C#.
I could find the page number, and line number easily using the
range.get_Information() method, but I could not find the information of
text-column number.
Note: I mean the text-column NOT the column number in a table.
and here is a portion of the code:
//
// After the document is opened using app.Documents.Open()
//
foreach (Microsoft.Office.Interop.Word.Range range in document.Words)
{
string text = range.Text;
lineNo =
(int)range.get_Information(Microsoft.Office.Interop.Word.WdInformation.wdFirstCharacterLineNumber);
pageNo =
(int)range.get_Information(Microsoft.Office.Interop.Word.WdInformation.wdActiveEndPageNumber);
float lineY =
(float)range.Characters.Last.get_Information(Microsoft.Office.Interop.Word.WdInformation.wdVerticalPositionRelativeToPage);
float wordX =
(float)range.get_Information(Microsoft.Office.Interop.Word.WdInformation.wdHorizontalPositionRelativeToPage);
//.. Here I need to know the text-column number of the current range.
//
}
please help,
Thanks in advance