> >*---------------------------------------------------- >function SearchAndReplace_Word > lparameters WordObj, SearchFor, ReplaceWith, MatchCase, MatchWholeWord, ; > MatchWildCards, MatchSoundsLike, MatchAllWordForms, FormatInfoAlso > > #define wdFindStop 0 > #define wdFindContinue 1 > #define wdFindAsk 2 > > #define wdReplaceNone 0 > #define wdReplaceOne 1 > #define wdReplaceAll 2 > > local Forward, Wrap > > for each StoryRange in WordObj.ActiveDocument.StoryRanges > with StoryRange > .WholeStory > .Find.ClearFormatting > .Find.Replacement.ClearFormatting > > Forward = TRUE > Wrap = wdFindContinue > > && replacement max 254 chars > do case > case len(ReplaceWith) <= 254 > =StoryRange.Find.Execute(SearchFor, MatchCase, MatchWholeWord, MatchWildCards, MatchSoundsLike, MatchAllWordForms, Forward, Wrap, FormatInfoAlso, ReplaceWith, wdReplaceAll, , , , ) > otherwise > local x, xReplace, ReplaceLeft > ReplaceLeft = ReplaceWith > > do while !empty(len(ReplaceLeft) ) > do case > case len(ReplaceLeft) < 255 > xReplace = ReplaceLeft > ReplaceLeft = '' > otherwise > xReplace = left(ReplaceLeft, 254 - len(SearchFor)) + SearchFor > ReplaceLeft = Substr(ReplaceLeft, 254 - len(SearchFor) + 1) > endcase > > =StoryRange.Find.Execute(SearchFor, MatchCase, MatchWholeWord, MatchWildCards, MatchSoundsLike, MatchAllWordForms, Forward, Wrap, FormatInfoAlso, xReplace, wdReplaceAll, , , , ) > > enddo > endcase > endwith > endfor > #undefine wdFindStop > #undefine wdFindContinue > #undefine wdFindAsk > > #undefine wdReplaceNone > #undefine wdReplaceOne > #undefine wdReplaceAll >endfunc >*-------------------------------------------------------------------------- >>>Hi