View Single Post
 
Old 10-14-2022, 06:39 AM
laith93 laith93 is offline Windows 10 Office 2019
Competent Performer
 
Join Date: Jul 2021
Posts: 117
laith93 is on a distinguished road
Default Applying a VBA code to current paragraph without being selected

Hi,
Please, how to apply a VBA code to the current paragraph without selecting it at all (in general), in my case, I want to apply a find and replace VBA code to the current paragraph without selecting it (just the pointer is in)

Code:
Sub TestV2()
'
'
  Dim Rng As range
 Set Rng = Selection.range


    With Rng.Find
        .Text = "[ñõðóòö~úø]"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchKashida = False
        .MatchDiacritics = False
        .MatchAlefHamza = False
        .MatchControl = False
        .MatchWildcards = True
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub
I used
Selection.Paragraphs(1).range
for Rng
but does not work
Thanks
Reply With Quote