JFamilo,
You're nearly there!
Use Excel VBA to open the Word Doc., put the data in the bookmarks and print
the doc.
Put this all in a loop to go through each of your templates in turn.
Here's some code I wrote to do just that.
You'll need to change the names of the bookmarks, file locations and
variables to suit your needs.
You'll also need to change it from looping through worksheets and rows to
looping through templates.
Dim appWD As Word.Application
'Set-up appWD
Set appWD = CreateObject("Word.Application.9") 'Open M.S.
Word (the 9 refers to Word 2000, use 10 for Word XP)
appWD.Visible = False
'Hide word window if you don't want to see the word doc.
appWD.ChangeFileOpenDirectory Sheets("System").Range("MyPath").Value
'Word looks here for file path
appWD.Documents.Open Filename:="ACM23", ConfirmConversions:=False,
ReadOnly:=True, _
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="",
Revert:=False, _
WritePasswordDocument:="", WritePasswordTemplate:="",
Format:=wdOpenFormatAuto 'Open doc
For gCounter = 2 To 3
'Look at each Worksheet
Worksheets(gCounter).Activate
For gMyRow = 3 To Worksheets(gCounter).UsedRange.Rows.Count
'Look at each row
If Worksheets(gCounter).Cells(gMyRow, 14).Value = "" _
And Worksheets(gCounter).Cells(gMyRow, 1).Value <> "" Then
'Exclude blank lines
If DateValue(Worksheets(gCounter).Cells(gMyRow, 10).Value) <
DateAdd("d", Date, -14) _
And Worksheets(gCounter).Cells(gMyRow, 11).Value = "" Then
'Found an outstanding first reminder
Worksheets(gCounter).Cells(gMyRow, 11).Value = Date
'Note reminder sent
'********************************************************
'print first reminders
'*******************************************************
appWD.ActiveDocument.FormFields("Title").Select
'Title
appWD.ActiveDocument.FormFields("Title").Result =
Worksheets(gCounter).Cells(gMyRow, 2).Value
appWD.ActiveDocument.FormFields("Title2").Select
'Title
appWD.ActiveDocument.FormFields("Title2").Result =
Worksheets(gCounter).Cells(gMyRow, 2).Value
appWD.ActiveDocument.FormFields("Initial").Select
'Initial
appWD.ActiveDocument.FormFields("Initial").Result =
Worksheets(gCounter).Cells(gMyRow, 3).Value
'Initial
appWD.ActiveDocument.FormFields("Surname").Select
'Surname
appWD.ActiveDocument.FormFields("Surname").Result =
Worksheets(gCounter).Cells(gMyRow, 4).Value
'Surname
appWD.ActiveDocument.FormFields("Surname2").Select
'Surname
appWD.ActiveDocument.FormFields("Surname2").Result =
Worksheets(gCounter).Cells(gMyRow, 4).Value
'Surname
appWD.ActiveDocument.FormFields("number").Select
'House/flat number
appWD.ActiveDocument.FormFields("number").Result =
Worksheets(gCounter).Cells(gMyRow, 5).Value
'Number
appWD.ActiveDocument.FormFields("Address1").Select
'First line of address
appWD.ActiveDocument.FormFields("Address1").Result =
Worksheets(gCounter).Cells(gMyRow, 6).Value
'Address1
If Worksheets(gCounter).Cells(gMyRow, 7).Value <> "" Then
Worksheets(gCounter).Cells(gMyRow, 7).Value = _
Worksheets(gCounter).Cells(gMyRow, 7).Value & ","
End If
appWD.ActiveDocument.FormFields("Address2").Select
'Second line of address
appWD.ActiveDocument.FormFields("Address2").Result =
Worksheets(gCounter).Cells(gMyRow, 7).Value
'Address2
appWD.ActiveDocument.FormFields("Postcode").Select
'Postcode
appWD.ActiveDocument.FormFields("Postcode").Result =
Worksheets(gCounter).Cells(gMyRow, 8).Value
'Postcode
appWD.ActiveDocument.FormFields("No").Select
'No
appWD.ActiveDocument.FormFields("No").Result =
Worksheets(gCounter).Cells(gMyRow, 1).Value
'No
appWD.ActiveDocument.FormFields("SentDate").Select
'Date review sent
appWD.ActiveDocument.FormFields("SentDate").Result =
Worksheets(gCounter).Cells(gMyRow, 10).Value
appWD.ActiveDocument.FormFields("Date").Select
'Date of letter
appWD.ActiveDocument.FormFields("Date").Result = Date
appWD.PrintOut
'Print letter
Application.Wait Time + TimeValue("00:00:05")
'Delay to let printing finish
End If
Next gMyRow
Next gCounter
Application.Wait Time + TimeValue("00:00:05")
'Delay to let printing finish
appWD.DisplayAlerts = wdAlertsNone
'Turn off alerts
appWD.Quit SaveChanges:=False
'Quit word
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Henry