I'm using VSTO ThisAddIn and Word 2013.
I want to replace all occurences of the one string with another using Find.Execute
and mark this action with custom undo message. The code is:
application.UndoRecord.StartCustomRecord("Some Message");
var find = application.ActiveDocument.Content.Find;
find.Execute("string to be replaced"
, ReplaceWith: "second string"
, Replace: WdReplace.wdReplaceAll);
application.EndCustomRecord();
So I have a Word Crash during this code run. If I change Replace: WdReplace.wdReplaceAll
to Replace: WdReplace.wdReplaceOne
, I'll have word working, but I need to replace all occurrences.
Any suggestions/workarounds?
It's some issue with Word when you have an empty custom undo and do a replace all. I just ran into this issue today.
This page explains it well.
Options