I am trying to:
1) copy an existing document (text) into a new document (done)
2) perform a search/replace on the new document (help!)
3) save the new document
I can get it to replace etc.. on the existing document, but not the new one. Any ideas on how to do this? Really stuck!
everytime I try to execute the Content.Find.Execute() method on the new document, it returns false
Code:aDoc.Activate(); object replaceAll = Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll; aDoc.Select(); aDoc.Content.Copy(); allDocument.Activate(); allDocument.Content.Paste(); //paste into new doc Paragraph para; para = allDocument.Content.Paragraphs.Add(ref missing); para.Range.InsertParagraphAfter(); allDocument.Activate(); allDocument.Content.Select(); allDocument.Content.Find.ClearFormatting(); allDocument.Content.Find.Text = "[namehere]"; allDocument.Content.Find.Replacement.Text = currentGuest.Lastname + ", " + currentGuest.Firstname; bool result = allDocument.Content.Find.Execute(ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref replaceAll, ref missing, ref missing, ref missing, ref missing);






any chance of a regain? 
Reply With Quote