Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 11-20-2018, 04:01 AM
yolandal yolandal is offline How can I combine the code for Search + Replace? Windows 10 How can I combine the code for Search + Replace? Office 2019
Novice
How can I combine the code for Search + Replace?
 
Join Date: Nov 2018
Posts: 2
yolandal is on a distinguished road
Question How can I combine the code for Search + Replace?

Hi there,
For certain documents I'm using this code to make automatisch Search + Replace, but the code is getting very long.
Is there a way to combine, strip or trim this code, as most of it is the same for every change?

In that case I will have a better view of what I'm doing, instead of a code with 2000+ rules.

Thank you for your time.

Yolanda





Sub Ams1()
'
' Ams1 Macro
'
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = " "
.Replacement.Text = " "
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With


Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = " "
.Replacement.Text = " "
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False

End Sub
Reply With Quote
 

Tags
code, replace, search



Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I combine the code for Search + Replace? Need some vba code to search a word document an replace it if len = 3 Belleke Word VBA 3 10-24-2016 01:00 AM
Search Replace Code BolligeA1 Word 8 02-22-2016 12:32 PM
How can I combine the code for Search + Replace? Need code to combine PDF files. D1TrueGod Word VBA 4 08-15-2015 06:15 AM
Search and replace/insert HTML code into Master File using tags dave8555 Excel 2 02-23-2014 03:51 PM
How can I combine the code for Search + Replace? Please help me to combine these code together lbf200n Word VBA 3 12-09-2012 04:22 PM

Other Forums: Access Forums

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


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