Thread: Replace String
View Single Post
 
Old 02-17-2022, 02:39 AM
ranjan ranjan is offline Windows 10 Office 2019
Advanced Beginner
 
Join Date: May 2021
Posts: 80
ranjan is on a distinguished road
Default

Hi,

Thanks Graham Mayor its quite working well and I liked how you did it so simply, but After running a macro one table enter is creating for every first row of a table. it can be avoided or not.

Upon your initiation, I tried it another way, and it worked well.

Thanks a lot for your help...

Code:
Sub Test_Replace()
Dim oTable As Table
Dim oCell As Range
    For Each oTable In ActiveDocument.Tables
        Set oCell = oTable.Cell(1, 1).Range
        oCell.Find.Execute FindText:="simple", ReplaceWith:="Simple", Replace:=wdReplaceAll
    Next oTable
    Set oCell = Nothing
    Set oTable = Nothing
End Sub
Reply With Quote