Set variables with information to print on all the labels for this order:
strCategory = rstOrder![CategoryName]
strOrderDate = CStr(rstOrder![OrderDate])
strShipName = rstOrder![ShipName]
strShipAddress = rstOrder![ShipAddress]
strShipCityStatePC = rstOrder![ShipCityStatePC]
strShipCountry = rstOrder![ShipCountry]
strSupplier = rstOrder![Supplier]
strShipDate = Format(Date, “dd-mmm-yyyy”)
Set up a loop to print a set of labels for this order, one label per case shipped:
For lngCaseNo = 1 To lngNoCases
With appWord.Selection
Put data into one label (one cell in the Word document):
.TypeText Text:=”FROM:” & vbTab
.MoveLeft Unit:=wdCharacter, Count:=1
.MoveLeft Unit:=wdWord, Count:=2, _
Extend:=wdExtend
.Font.Bold = True
.EndKey Unit:=wdLine
.Font.Bold = False
.TypeText Text:=”Northwind Traders”
.TypeParagraph
Indent the left margin to match the tab setting, so the address will line up with the name.
Instead of looking up Word methods, properties, and other object model components in
the Object Browser, you can capture the syntax for a Word action by recording a macro
in Word, then copying and pasting the VBA code into your Access VBA procedure. Just insert your
Word application variable where needed and trim the arguments you don’t need to prepare the code
for use in Access.
.ParagraphFormat.TabIndent (1)
.TypeText Text:=”2839 El Presidio St.”
.TypeParagraph
.TypeText Text:=”Nowhere, WA 92838”
.TypeParagraph
Return to the normal left margin before printing “TO:”:
.ParagraphFormat.LeftIndent = 8
.TypeParagraph
.Font.Bold = True
.TypeText Text:=”TO:” & vbTab
.MoveLeft Unit:=wdCharacter, Count:=1
.MoveLeft Unit:=wdCharacter, Count:=3, _
Extend:=wdExtend
NOTENOTE
Going Beyond the Basics 12