VB Script automate Microsoft Word Table Cell Content Replace Part of Text

I have a couple hundred Microsoft Word Tables each with a cell with the following value
FY 2016
Actual

I need to increment the year and attempted this way which did not do anything:

dim newval
newval = "2017"
call replace(tbl.cell(row,2).range.text,"2016",newval)

Question:  How can I modify this code so that it replaces the 2016 with 2017?

If possible I wish to keep the original text and just replace the 2016.  
That way I do not loose the line break
maxdbaseAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
you can try:

Sub test()
    Dim oldval, newval, Row, Col
    Dim tbl As Table
    
    oldval = "2016"
    newval = "2017"
    Row = 1
    Col = 2
    
    Set tbl = ActiveDocument.Tables(1)
    If InStr(1, tbl.Cell(Row, Col).Range.Text, oldval, vbTextCompare) Then
        tbl.Cell(Row, Col).Range.Text = newval
    End If
End Sub

Open in new window

0
Rgonzo1971Commented:
Hi,

pls try
Sub Macro()
  
    oldval = "2016"
    newval = "2017"
    Row = 1
    
    Set tbl = ActiveDocument.Tables(1)
    If InStr(1, tbl.Cell(Row, 2).Range.Text, oldval, vbTextCompare) Then
        res = Replace(tbl.Cell(Row, Col).Range.Text, oldval, newval)
        tbl.Cell(Row, Col).Range.Text = Left(res, Len(res) - 2)
    End If
End Sub

Open in new window

Regards
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.