In my app I'm editing a word document, I want to modify some values but I want the changes to affect the first page, only:
The content of the first page is like:
USER:
COMPANY:
and I want to modify it to:
USER: aaa
COMPANY: bbb
I have tried like:
//properties
object objMiss = System.Reflection.Missing.Value;
object objEndOfDocFlag = "\\endofdoc"; /* \endofdoc is a predefined bookmark */ //Start Word and create a new document.
Microsoft.Office.Interop.Word._Application objApp;
Microsoft.Office.Interop.Word._Document objDoc;
//load the document:
objDoc = objApp.Documents.Open(@"C:\Users\BugsFixer\file.docx", ref objMiss, ref objMiss, ref objMiss, ref objMiss, ref objMiss, ref objMiss, ref objMiss, ref objMiss, ref objMiss, ref objMiss, ref objMiss, ref objMiss, ref objMiss, ref objMiss, ref objMiss);
int count = objDoc.Words.Count;
for (int i = 1; i <= count; i++)
{
string text = objDoc.Words[i].Text;
if (text.StartsWith("USER"))
objDoc.Words[i].Text = "USER: aaa";
if (text.StartsWith("COMPANY"))
objDoc.Words[i].Text = "COMPANY: bbb";
}
but this woud change all "USER" strings. I need something like:
if(current page is one)
{
//replace USER with USER:aaa
//replace COMPANY with COMPANY:bbb
}
How to check that I'm editing a specific page i.e in my case page 1?