Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-18-2018, 07:45 AM
sipi1988 sipi1988 is offline Word 2016 - Find and replace message box need to be removed Windows 10 Word 2016 - Find and replace message box need to be removed Office 2016
Novice
Word 2016 - Find and replace message box need to be removed
 
Join Date: Jan 2018
Posts: 2
sipi1988 is on a distinguished road
Default Word 2016 - Find and replace message box need to be removed


Hi!

I have a macro mainly about find and replace, how could I eliminate the message box which always asks me to start the searching from the begining. I always have to click onto the no button several times. Would be nice if macro could do it instead of me.

Thanks in advance

Code:
Sub PDM_csillagos()
'
' PDM_csillagos Makró
'
'
    Selection.WholeStory
    Selection.PasteAndFormat (wdFormatPlainText)
    Selection.WholeStory
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = """"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    With Selection.Find
        .Text = "?"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    With Selection.Find
        .Text = "^p"
        .Replacement.Text = "*;"
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    With Selection.Find
        .Text = "*;*"
        .Replacement.Text = "*;"
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    With Selection.Find
        .Text = ";*;"
        .Replacement.Text = ";"
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    Selection.WholeStory
    Selection.Copy
End Sub
Reply With Quote
  #2  
Old 01-18-2018, 09:27 AM
Souriane Souriane is offline Word 2016 - Find and replace message box need to be removed Windows 7 64bit Word 2016 - Find and replace message box need to be removed Office 2013
Advanced Beginner
 
Join Date: Feb 2017
Location: Quebec, Canada
Posts: 82
Souriane is on a distinguished road
Default

Hi!

Change each line ".Wrap = wdFindAsk"

with "Wrap = wdFindContinue"

Bye!

Souriane
Reply With Quote
  #3  
Old 01-18-2018, 03:17 PM
macropod's Avatar
macropod macropod is offline Word 2016 - Find and replace message box need to be removed Windows 7 64bit Word 2016 - Find and replace message box need to be removed Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Your code is very inefficient. Try:
Code:
Sub PDM_csillagos()
Application.ScreenUpdating = False
With ActiveDocument.Range
    .PasteAndFormat (wdFormatPlainText)
    With .Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Format = False
        .Forward = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .Wrap = wdFindContinue
        .Text = """"
        .Replacement.Text = ""
        .Execute Replace:=wdReplaceAll
        .Text = "?"
        .Replacement.Text = ""
        .Execute Replace:=wdReplaceAll
        .Text = "^p"
        .Replacement.Text = "*;"
        .Execute Replace:=wdReplaceAll
        .Text = "*;*"
        .Replacement.Text = "*;"
        .Execute Replace:=wdReplaceAll
        .Text = ";*;"
        .Replacement.Text = ";"
        .Execute Replace:=wdReplaceAll
    End With
    .Copy
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #4  
Old 01-19-2018, 12:30 AM
sipi1988 sipi1988 is offline Word 2016 - Find and replace message box need to be removed Windows 10 Word 2016 - Find and replace message box need to be removed Office 2016
Novice
Word 2016 - Find and replace message box need to be removed
 
Join Date: Jan 2018
Posts: 2
sipi1988 is on a distinguished road
Default

Thank you for both of you for the fast responses, works fine!
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
In Find and Replace, can Word stop after each Replace? wardw Word 1 06-08-2017 02:47 PM
Word 2016 - Find and replace message box need to be removed MS Word 2016 Find and Replace BillM Word 2 03-14-2017 10:49 AM
Word 2016 - Find and replace message box need to be removed Multiple find and replace Word 2016 benpk1 Word VBA 5 03-01-2017 02:41 AM
Word 2016 - Find and replace message box need to be removed Need help using Find & Replace (MS Word) BZee Word 9 02-16-2015 05:45 PM
Word 2016 - Find and replace message box need to be removed Bad view when using Find and Find & Replace - Word places found string on top line paulkaye Word 4 12-06-2011 11:05 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:52 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft