little help - macro to find text object and replace with current date

Hello.  I have put together this code but it seems I missed something.

All help is appreciated greatly.

1
2
3
4
5
6
7
8
9
Sub ReplaceTextCurrentPage()
    Dim txtFIND As String
    Dim txtREPLACE As String 

    txtFIND = ActiveDocument.FindShape("date")
    txtREPLACE = CStr(Date)

    ActivePage.TextReplace txtFIND, txtREPLACE, True, False
End Sub
Parents
  • sorry...let me use this code instead.  something is broken on line 9.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    Sub ReplaceText()
        Dim txtFIND As String 'The word you want to find and replace
        Dim txtREPLACE As String 'The new word to replace the old
        Dim s As Shape
        ActivePage.Layers("Titleblock").Activate
        txtFIND = "0/0/2020"
        txtREPLACE = CStr(Date)
    
        ActivePage.Layers("Titleblock").TextReplace txtFIND, txtREPLACE, True, False
    End Sub
    
Reply Children
No Data