End If
strNameTitleCompany = _
Nz(lst.Column(2, varItem))
strWholeAddress = _
Nz(lst.Column(5, varItem))
strContactName = _
Nz(lst.Column(1, varItem))
strCompanyName = _
Nz(lst.Column(7, varItem))
strJobTitle = Nz(lst.Column(8, varItem))
Process differently depending on whether the template is for labels or a list:
If Nz(InStr(strWordTemplate, “List”)) > 0 Then
Insert data into list:
With appWord.Selection
.TypeText Text:=strContactName
.MoveRight unit:=wdCell, Count:=1
.TypeText Text:=strJobTitle
.MoveRight unit:=wdCell, Count:=1
.TypeText Text:=strCompanyName
.MoveRight unit:=wdCell, Count:=1
End With
ElseIf Nz(InStr(strWordTemplate, “Labels”)) > 0 Then
lngCount = lngCount + 1
Insert data into labels, skipping narrow spacer columns:
With appWord.Selection
.TypeText Text:=strNameTitleCompany
.TypeParagraph
.TypeText Text:=strWholeAddress
.TypeParagraph
Use the Modoperator to handle every second or third record differently, in order to write data only
to valid cells:
lngSkip = lngCount Mod intMod
If lngSkip <> 0 Then
.MoveRight unit:=wdCell, Count:=2
ElseIf lngSkip = 0 Then
.MoveRight unit:=wdCell, Count:=1
End If
End With
End If
Working with Word Documents and Templates 6