Results 1 to 3 of 3

Thread: [RESOLVED] Search and Replace without confirmation

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2017
    Posts
    5

    Resolved [RESOLVED] Search and Replace without confirmation

    Hi, I am using the following code to search and replace some text however it asks the user after the replacement "Do you want to continue searching from the beginning?" How can I automate this to be yes and have no user input.


    Code:
        Selection.WholeStory
        Selection.Find.ClearFormatting
        Selection.Find.Replacement.ClearFormatting
        With Selection.Find
            .Text = "Sub-Contractor"
            .Replacement.Text = "Sub-Sub-Contractor"
            .Forward = True
            .Wrap = wdFindContinue
            .Wrap = wdFindAsk
            .Format = False
            .MatchCase = False
            .MatchWholeWord = False
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
        End With
        Selection.Find.Execute replace:=wdReplaceAll

    Thanks
    Attached Images Attached Images  

  2. #2
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    Re: Search and Replace without confirmation

    If you don't want it to Ask, then why do you set it to ask?

    .Wrap = wdFindAsk

    The previous line

    .Wrap = wdFindContinue

    would continue the search automatically without asking, but then you override that setting on the next line.

    https://msdn.microsoft.com/en-us/lib...ffice.11).aspx
    Last edited by passel; Dec 9th, 2017 at 10:35 AM.

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2017
    Posts
    5

    Re: Search and Replace without confirmation

    Thanks, that was a bit silly of me!!

    Cheers fixed my issue. Thanks again.

Posting Permissions

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



Click Here to Expand Forum to Full Width