Thread: Replace String
View Single Post
 
Old 02-17-2022, 01:31 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

It would be simpler just to replace 'sample' with 'Sample' in the first cell of each table e.g.
Code:
Sub Macro1()
Dim oTable As Table
Dim oCell As Range
    For Each oTable In ActiveDocument.Tables
        Set oCell = oTable.Cell(1, 1).Range
        oCell.Text = Replace(oCell.Text, "sample", "Sample")
    Next oTable
    Set oCell = Nothing
    Set oTable = Nothing
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote