Check for required address information:
strTest = Nz(lst.Column(5, varItem))
Debug.Print “Street address: “ & strTest
If strTest = “” Then
Debug.Print “Skipping this record -- no address!”
GoTo NextContact
End If
strTest = Nz(lst.Column(1, varItem))
Debug.Print “Contact name: “ & strTest
If strTest = “” Then
Debug.Print _
“Skipping this record -- no contact name!”
GoTo NextContact
End If
strContactName = _
Nz(lst.Column(1, varItem))
strCompanyName = _
Nz(lst.Column(7, varItem))
strNameTitleCompany = _
Nz(lst.Column(2, varItem))
strWholeAddress = _
Nz(lst.Column(5, varItem))
Open a new document based on the selected template:
Set appWord = GetObject(Class:=”Word.Application”)
appWord.Documents.Add strWordTemplate
Write information to Word bookmarks, first turning off the error handler because some templates
don’t have all of these bookmarks:
On Error Resume Next
With appWord.Selection
.GoTo what:=wdGoToBookmark, _
Name:=”NameTitleCompany”
.TypeText Text:=strNameTitleCompany
.GoTo what:=wdGoToBookmark, _
Name:=”WholeAddress”
.TypeText Text:=strWholeAddress
.GoTo what:=wdGoToBookmark, Name:=”Salutation”
.TypeText Text:=Nz(lst.Column(10, varItem))
.GoTo what:=wdGoToBookmark, Name:=”TodayDate”
.TypeText Text:=strLongDate
Working with Word Documents and Templates 6