Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 12-28-2021, 09:51 PM
Bikram Bikram is offline Conditional_Replacing Windows 10 Conditional_Replacing Office 2007
Advanced Beginner
Conditional_Replacing
 
Join Date: Jul 2021
Location: Nepal
Posts: 97
Bikram is on a distinguished road
Default Conditional_Replacing

Hello, I am using find and replace and it seems to work fine but I need to modify it. Here is the code.



Code:
Sub findMm()
Dim strfind() As Variant
Dim strreplace() As Variant
Dim i As Integer
    strfind = Array("A", "An", "The", "To", "With" )
    strreplace = Array("a", "an", "the", "to","with")
    For i = 0 To UBound(strfind)
        With Selection.find
            .ClearFormatting
            .Replacement.ClearFormatting
            .Text = strfind(i)
            .Format = True
            .Forward = True
            .MatchWildcards = False
            .MatchCase = True
            .Replacement.Text = strreplace(i)
            .Execute Replace:=wdReplaceAll
        End With
    Next i
End Sub
What I want to do here is to replace the found items only if they are in the middle of the sentences and ignore them if they are at the beginning of the sentences.

For Example:
To Find The Answer Of The Question.
With The Help Of People.

Replace the text except for the first word

To Find the Answer to the Question.
With the help of People.

How can it be done?? Thanks in advance.
Reply With Quote
 



Other Forums: Access Forums

All times are GMT -7. The time now is 02:23 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