Word 2013 crashes when running a VBA/macro on a document that has comments section enabled. The macro searches for a character and replaces it with "" (blank) in the comments section and main document. This is done using Selection.Find.Execute
API. When there is no comments section or no mark up is selected, Word doesn't crash.
This is on Windows 10 and word 2013. The macro works well in Word 2007 and Windows 7.
Reproducible steps:
Create a simple document with one text and add comment.
Insert the sample comment text as below: (add vertically like: A : & (enter) and so on)
A: & B: & C: & D: & E: & F: & G: & H: & I: & J: & K: & L: & M: & N: &
Create macro:
Sub Test_Macro() ActiveWindow.View.SplitSpecial = wdPaneComments With Selection.Find .Text = "&" .Replacement.Text = "" .Forward = True .Wrap = wdFindStop .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.HomeKey unit:=wdStory If Selection.Find.Execute = True Then 'We found the slash. Delete it. Selection.TypeBackspace End If End Sub
Execute the Macro (
&
will be cleared). Keep on executing again; Word will crash 2-3 times out of 10. (update the comment text accordingly, when all&
s are cleared).