View Single Post
 
Old 09-05-2017, 02:11 AM
slaycock slaycock is offline Windows 7 64bit Office 2013
Expert
 
Join Date: Sep 2013
Posts: 255
slaycock is on a distinguished road
Default

Or if you really wanted to play around with ranges, but much less readable/understandable than above

Code:
Sub UpdateMyTips()

Dim myNewTip As Long
Dim myOldTotal As Long
    
   With ActiveDocument.Paragraphs(2).Range.Words(1)
        With .Previous(unit:=wdParagraph).Words(1)
            myNewTip = CLng(.Text)
            .Text = " " & vbCrLf
        End With
        myOldTotal = CLng(.Words(1).Text)
        .Words(1).Text = CStr(myNewTip + myOldTotal) & " "
        .Paragraphs(1).Range.InsertAfter Text:=myNewTip & " " & Format(Now(), "DDDD, MMMM d, yyyy") & vbCrLf
    End With
End Sub
Reply With Quote