Find All Words in Word 2003

D

David Sherman

I did a search on Google and found this macro:

The URL is :

http://www.pcreview.co.uk/forums/thread-884711.php

I get an comile error:

Selection.Sort ExcludeHeader:=False, FieldNumber:="Paragraphs", _
SortFieldType:=wdSortFieldAlphanumeric,

Is a fix to this?

thanks

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
..Text = " "
..Replacement.Text = "^p"
..Forward = True
..Wrap = wdFindContinue
..Format = False
..MatchCase = True
..MatchWholeWord = True
..MatchWildcards = False
..MatchSoundsLike = False
..MatchAllWordForms = False
End With
Selection.Find.Execute replace:=wdReplaceAll
Selection.Sort ExcludeHeader:=False, FieldNumber:="Paragraphs", _
SortFieldType:=wdSortFieldAlphanumeric,
SortOrder:=wdSortOrderAscending, _
FieldNumber2:="", SortFieldType2:=wdSortFieldAlphanumeric,
SortOrder2:= _
wdSortOrderAscending, FieldNumber3:="", SortFieldType3:= _
wdSortFieldAlphanumeric, SortOrder3:=wdSortOrderAscending,
Separator:= _
wdSortSeparateByCommas, SortColumn:=False, CaseSensitive:=True, _
LanguageID:=wdEnglishUK, SubFieldNumber:="Paragraphs",
SubFieldNumber2:= _
"Paragraphs", SubFieldNumber3:="Paragraphs"
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
..Text = "(*^13)@"
..Replacement.Text = "\1"
..Forward = True
..Wrap = wdFindAsk
..Format = False
..MatchCase = True
..MatchWholeWord = True
..MatchAllWordForms = False
..MatchSoundsLike = False
..MatchWildcards = True
End With
Selection.Find.Execute replace:=wdReplaceAll
 
J

Jay Freedman

Hi David,

Your copy of the macro has line breaks where they shouldn't be. You need
more line-continuation characters (the space-and-underscore that you see at
the ends of some of the lines, explained at
http://word.mvps.org/FAQs/MacrosVBA/_AtEndOfLine.htm), like this:

Selection.Sort ExcludeHeader:=False, FieldNumber:="Paragraphs", _
SortFieldType:=wdSortFieldAlphanumeric, _
SortOrder:=wdSortOrderAscending, _
FieldNumber2:="", SortFieldType2:=wdSortFieldAlphanumeric, _
SortOrder2:= _
wdSortOrderAscending, FieldNumber3:="", SortFieldType3:= _
wdSortFieldAlphanumeric, SortOrder3:=wdSortOrderAscending, _
Separator:= _
wdSortSeparateByCommas, SortColumn:=False, CaseSensitive:=True, _
LanguageID:=wdEnglishUK, SubFieldNumber:="Paragraphs", _
SubFieldNumber2:= _
"Paragraphs", SubFieldNumber3:="Paragraphs"

Note: I have *not* loaded this macro to see whether it works. If you find
any further errors or failures, please post in the
microsoft.public.word.vba.beginners newsgroup, not here.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
D

David Sherman

Thanks for your remarks.
My comments:

1. I don't see how copy and pasting the macro from the link that I
provided would contain line breaks wrongly.

2. Since the macro came from this news group, I posted it here.

3. when I googled this macro, I found no reference where it worked on
not.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top