Dave T
10-01-2011, 07:22 AM
Hello All,
At work I use a macro to apply strikethrough to selected/highlighted text to show text that is to be deleted and use another macro that underlines text that is to be added.
When highlighted text additions/deletions have been approved I have previously manually selected each word/words with strikethrough and deleted them.
I am after a macro that operates in the same way as the ‘Find’ and ‘Replace’ dialogue in word.
I found a macro by Greg Maxey that does the whole document in one go (http://www.officekb.com/Uwe/Forum.aspx/word-vba/23185/Macro-to-find-and-delete-strikethrough), but it only deleted the strikethrough text and left extra spaces.
Then I found another macro by Doug Robbins (http://hewreck.com/qanda/replies/find-and-loop-macro-1121577) which does the same as Greg’s but does not leave spaces.
Sub DeleteStrikethroughTextV2()
'http://hewreck.com/qanda/replies/find-and-loop-macro-1121577
'Doug Robbins
Dim myRange As Range
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
With .Font
.StrikeThrough = True
.DoubleStrikeThrough = False
End With
Do While .Execute(findText:="", Wrap:=wdFindContinue, Forward:=True) = True
Set myRange = Selection.Range
myRange.End = myRange.End + 1
If Right(myRange, 1) = " " Then
myRange.Delete
Else
myRange.Start = myRange.Start - 1
myRange.End = myRange.End - 1
myRange.Delete
End If
Loop
End With
End Sub
This macro works exactly as I am looking for but it does the whole document in one action and does not give you time to see what is going to be deleted.
I am seeking help to modify Doug’s code so that a vbYesNoCancel message box can be used to step through the document so I can see each word or range of words with strikethrough and decide whether or not to delete them.
Any help would be appreciated.
PS Forgot to mention I am using Word 2003
Regards,
Dave T
At work I use a macro to apply strikethrough to selected/highlighted text to show text that is to be deleted and use another macro that underlines text that is to be added.
When highlighted text additions/deletions have been approved I have previously manually selected each word/words with strikethrough and deleted them.
I am after a macro that operates in the same way as the ‘Find’ and ‘Replace’ dialogue in word.
I found a macro by Greg Maxey that does the whole document in one go (http://www.officekb.com/Uwe/Forum.aspx/word-vba/23185/Macro-to-find-and-delete-strikethrough), but it only deleted the strikethrough text and left extra spaces.
Then I found another macro by Doug Robbins (http://hewreck.com/qanda/replies/find-and-loop-macro-1121577) which does the same as Greg’s but does not leave spaces.
Sub DeleteStrikethroughTextV2()
'http://hewreck.com/qanda/replies/find-and-loop-macro-1121577
'Doug Robbins
Dim myRange As Range
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
With .Font
.StrikeThrough = True
.DoubleStrikeThrough = False
End With
Do While .Execute(findText:="", Wrap:=wdFindContinue, Forward:=True) = True
Set myRange = Selection.Range
myRange.End = myRange.End + 1
If Right(myRange, 1) = " " Then
myRange.Delete
Else
myRange.Start = myRange.Start - 1
myRange.End = myRange.End - 1
myRange.Delete
End If
Loop
End With
End Sub
This macro works exactly as I am looking for but it does the whole document in one action and does not give you time to see what is going to be deleted.
I am seeking help to modify Doug’s code so that a vbYesNoCancel message box can be used to step through the document so I can see each word or range of words with strikethrough and decide whether or not to delete them.
Any help would be appreciated.
PS Forgot to mention I am using Word 2003
Regards,
Dave T