Re: Code Mod to prevent further .Replacement.Text over complete Document.
Hi, I got this simple code from a macro recording.
. Its purpose is to replace a space between text in the current selection with 2 spacesCode:Sub space1to2() ' Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = " " .Replacement.Text = " " .Forward = True ' .Wrap = wdFindAsk'This stops asking if whole doco should be done, and it does not then do whole doco ' .Format = False ' .MatchCase = False ' .MatchWholeWord = False ' .MatchKashida = False ' .MatchDiacritics = False ' .MatchAlefHamza = False ' .MatchControl = False ' .MatchWildcards = False ' .MatchSoundsLike = False ' .MatchAllWordForms = False End With 'Application.DisplayAlerts = False'These pair prevents me being asked BUT will cause the whole doco to be done!!!! Selection.Find.Execute Replace:=wdReplaceAll 'Application.DisplayAlerts = True End Sub
. I did some simple mods ( mostly just commenting out lines that I did not think did anything )
. I wanted to modify the code so that it does not ask me if I want to continue doing the replacement for the whole WORD document BUT ALSO that it does not then actually do that.
. I did try the Application.DisplayAlerts = False Application.DisplayAlerts = True Pair. This did prevent me being asked, BUT then the code goes on to do the replacement across the whole WORD Document. ( Which I do not want )
. Can anyone modify my code to achieve this.
Many Thanks
Alan Elston




Reply With Quote
Bookmarks