Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-14-2019, 09:09 AM
koehlerc14 koehlerc14 is offline Function in a Macro used to Find & Replace Windows 10 Function in a Macro used to Find & Replace Office 2016
Novice
Function in a Macro used to Find & Replace
 
Join Date: Feb 2019
Posts: 6
koehlerc14 is on a distinguished road
Default Function in a Macro used to Find & Replace

I have a Macro that I'm trying to make more efficient and also be able to share & update a little easier. My attempt was to create a function that could be called for upwards of 25 corrections that change over time and should be easy to update with just one line of code calling the function.



Can anyone deduce what I am trying to do and what I'm writing incorrectly?

Code:
Private Function Simple_FindReplace(docFind As Document, strFind As String, _
                                    strReplace As String)
 
        With docFind.Range.Find
            .ClearFormatting
            .Replacement.ClearFormatting
            .Text = strFind
            .Replacement.Text = strReplace
            .Execute Replace:=wdReplaceAll
        End With
End Function
Sub DocOps_SPD_Rewrites()
    With Document.Range.Find
 
    'SPD Changes - Updated 2.14.2019
 
          Call Simple_FindReplace("BEFORE text", "AFTER text")
          Call Simple_FindReplace("BEFORE test", "AFTER test")
          Call Simple_FindReplace("BEFORE tent", "AFTER tent")
    End With
End Sub
Reply With Quote
 



Other Forums: Access Forums

All times are GMT -7. The time now is 09:27 PM.


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