Results 1 to 4 of 4

Thread: Code Mod to prevent further .Replacement.Text over complete Document.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,458
    Rep Power
    10

    Code Mod to prevent further .Replacement.Text over complete Document.

    Re: Code Mod to prevent further .Replacement.Text over complete Document.

    Hi, I got this simple code from a macro recording.

    Code:
    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
    . Its purpose is to replace a space between text in the current selection with 2 spaces
    . 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
    Last edited by DocAElstein; 09-16-2015 at 03:48 PM.

Similar Threads

  1. Replies: 2
    Last Post: 01-27-2015, 08:29 PM
  2. Replies: 0
    Last Post: 01-24-2015, 03:50 PM
  3. Replies: 1
    Last Post: 08-21-2014, 12:16 AM
  4. Replies: 2
    Last Post: 06-08-2013, 09:32 PM
  5. Replacement for TreeView
    By Rasm in forum Excel Help
    Replies: 2
    Last Post: 11-26-2011, 08:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •