C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,292 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello Guys,
I want to find x, y coordinates of particular word in word document using inotrope or any other library in C#
pls suggest me
Thanks!!!
A way with Word Interop :
Microsoft.Office.Interop.Word.Application oWordApplication = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word.Documents oWordDocuments = oWordApplication.Documents;
Microsoft.Office.Interop.Word.Document oWordDocument = oWordDocuments.Open(@"e:\\test.doc");
//oWordApplication.Visible = true;
object oFindText = "test";
object oMissing = System.Reflection.Missing.Value;
Microsoft.Office.Interop.Word.Range range = oWordApplication.ActiveDocument.Content;
while (true)
{
range.Find.Execute(
ref oFindText, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
if (range.Find.Found)
{
int nLine = range.get_Information(Microsoft.Office.Interop.Word.WdInformation.wdFirstCharacterLineNumber);
int nColumn = range.get_Information(Microsoft.Office.Interop.Word.WdInformation.wdFirstCharacterColumnNumber);
MessageBox.Show(string.Format("Line = {0} - Column {1}\r\n", nLine, nColumn), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
break;
}
oWordApplication.Quit();
Marshal.ReleaseComObject(oWordDocument);
Marshal.ReleaseComObject(oWordDocuments);
Marshal.ReleaseComObject(oWordApplication);