Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
973 B
2
Indexable
Never
' Replace placeholders in the letter template with dynamic data
With wordDoc.Content.Find
    .Text = "<Date>"
    .Replacement.Text = dateStr
    .Execute Replace:=wdReplaceAll
    If .Found = False Then
        MsgBox "Error: Placeholder <Date> not found.", vbExclamation
    End If
    
    .Text = "<RecipientName>"
    .Replacement.Text = recipientName
    .Execute Replace:=wdReplaceAll
    If .Found = False Then
        MsgBox "Error: Placeholder <RecipientName> not found.", vbExclamation
    End If
    
    .Text = "<Address>"
    .Replacement.Text = recipientAddress
    .Execute Replace:=wdReplaceAll
    If .Found = False Then
        MsgBox "Error: Placeholder <Address> not found.", vbExclamation
    End If
    
    .Text = "<APEAmount>"
    .Replacement.Text = apeAmount
    .Execute Replace:=wdReplaceAll
    If .Found = False Then
        MsgBox "Error: Placeholder <APEAmount> not found.", vbExclamation
    End If
End With
Leave a Comment