I use something like this:
doc.Content.Find.Font.Name = \"Times New Roman\";
but when I step through the code the Name property doesn\'t change
I believe you need to obtain a FIND object and then use it, when you refer to the object via dot notation like you have, you're always getting a brand new FIND object, so you'll loose your settings each time.
Something like this
With Doc.content.Find
.clearFormatting
.Font.name = "blah"
.Execute .....
End With
I used this:
Microsoft.Office.Interop.Word._Application word;
Microsoft.Office.Interop.Word._Document doc;
bool found_next = false;
private void search_Replace1()
{
word = Globals.ThisAddIn.Application;
doc = word.ActiveDocument;
word.Selection.Find.Font.Name = "My Font";
found_next= word.Selection.Find.Execute(Format: true);
if (found_next)
{
word.Selection.Font.Name = "Arial";
//word.Selection.Font.ColorIndex = Microsoft.Office.Interop.Word.WdColorIndex.wdRed; //change color to red
}
}
Thanks for your reply, but no you don't get a new Find object each time you use dot notation. The problem is you shouldn't use Doc.Content.Find in this kind of situation. Instead you have to create a new Range object and use its Find. Something like this:
Word.Range range = doc.Range(0, doc.Content.End);