Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
I have a macro that can find all duplicate word pairs, highlight them, then play a sound to notify me as follow:
Sub CheckEnglishAndTypos() 'Go to the beginning to start the search Selection.HomeKey Unit:=wdStory Selection.Paragraphs(1).Range.Select Selection.Find.Highlight = False Selection.Find.Replacement.Highlight = True With Selection.Find .Text = "(*) \1" .Replacement.Text = "" .Forward = True .Wrap = wdFindStop .Format = True .MatchCase = False .MatchWholeWord = False .MatchWildcards = True .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll Do Until ActiveDocument.Bookmarks("\Sel").Range.End = ActiveDocument.Bookmarks("\EndOfDoc").Range.End 'Loop the search till the end Selection.MoveDown Unit:=wdLine, Count:=1 Selection.Paragraphs(1).Range.Select With Selection.Find .Text = "(*) \1" .Replacement.Text = "" .Forward = True .Wrap = wdFindStop .Format = True .MatchCase = False .MatchWholeWord = False .MatchWildcards = True .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll Loop ' Searching the remaning (till the end of document) Exit Sub Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting PlayTheSound "Task Completed.wav" End Sub This thing works like a charm on short documents, but for anything over 100 pages, it gives me the "Requested Member of the Collection Does Not Exist". In debug mode, the line corresponds to the error is "Do Until ActiveDocument.Bookmarks("\Sel").Range.End = ActiveDocument.Bookmarks("\EndOfDoc").Range.End". When I checked over the test document, apparently the thing did highlight everything to the end. But for some bloody reason, it couldn't find where the document end. So the macro just stopped, and no sound was played. Is there anyway to fix it? |
Reply |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
[Word 2016] Style lost on copy&paste | Microsoft Word Help | |||
Conversion of Microsoft Word VBA from windows version to Office 2016 for Mac. | Microsoft Word Help | |||
'addrow' VB macro error: requested member of collection does not e | Tables | |||
In Word symbol for a 1/16 of inche does not exist,where to find? | Microsoft Word Help | |||
Error 5941 - The requested member of the collection does not exsis | Microsoft Word Help |