I am a newbie at VBA. I have the code for my button to do one thing and now I am stuck. How do I get one button to fill in bookmarks on different documents. Here is my code and it is not working
Code:
Option Compare Database
Private Sub cmd_Word_Click()
'Declare Variables
Dim sAccessAddress As String
Dim Salutation As String
'Build sAccessAddress
sAccessAddress = FirstName & " " & LastName & vbCrLf & Address & vbCrLf & StateOrProvince & " " & Zipcode
'Build sAccessSalutation
Salutation = FirstName & " " & LastName
'Declare and set Word object variables
Dim Wrd As Word.Application
Set Wrd = CreateObject("Word.Application")
'Specify Path to Template
Dim sMergeDoc As String
Dim sMerge As String
sMergeDoc = Application.CurrentProject.Path & "\WordMergeDocument.dotx"
sMerge = Application.CurrentProject.Path & "C:\Users\dwilson\Desktop\Active Work\CertofRehab.dotx"
'Open Word using template and make Word visible
Wrd.Documents.Add sMergeDoc
Wrd.Documents.Add sMerge
Wrd.Visible = True
'Replace Bookmarks with Values
With Wrd.ActiveDocument.Bookmarks
.Item("CurrentDate").Range.Text = Date
.Item("AccessAddress").Range.Text = sAccessAddress
.Item("Salutation").Range.Text = sAccessSalutation
End With
'Open in PrintPreview mode, let user print
Wrd.ActiveDocument.PrintPreview
'Clean Up code
Set Wrd = Nothing
End Sub