VBA Snippets
EnvelopesPrint
Prints envelopes from the active document.Public Sub Doc_EnvelopesPrint()
On Error GoTo AnError
' ActiveDocument.Envelope.PrintOut ExtractAddress:=False, _
' OmitReturnAddress:=False, _
' PrintBarCode:=False, _
' PrintFIMA:=False, _
' Height:=InchesToPoints(4.13), _
' Width:=InchesToPoints(9.5), _
' Address:="Tom Howe", _
' AutoText:="ToolsCreateLabels1", _
' ReturnAddress:="1001 SW Fifth Avenue, Suite 1100", _
' ReturnAutoText:="ToolsCreateLabels2", _
' AddressFromLeft:=wdAutoPosition, _
' AddressFromTop:=wdAutoPosition, _
' ReturnAddressFromLeft:=wdAutoPosition, _
' ReturnAddressFromTop:=wdAutoPosition
If gbDEBUG = False Then Exit Sub
AnError:
Call Error_Handle("Doc_EnvelopesPrint", msMODULENAME, 1, _
"print the envelopes")
End Sub
LabelsPrint
Prints labels from the active document.Public Sub Doc_LabelsPrint()
On Error GoTo AnError
' Application.MailingLabel.DefaultPrintBarCode = False
' Application.MailingLabel.PrintOut Name:="2160 Mini", _
' Address:="Tom Howe", _
' AutoText:="ToolsCreateLabels3"
If gbDEBUG = False Then Exit Sub
AnError:
Call Error_Handle("Doc_LabelsPrint", msMODULENAME, 1, _
"print the labels")
End Sub
MailMerge
Performs a mailmerge from a database.Public Sub Doc_MailMerge()
On Error GoTo AnError
' ActiveDocument.MailMerge.MainDocumentType = wdFormLetters
' ActiveDocument.MailMerge.OpenDataSource Name:= _
' "C:\Automation\Northwind.MDB", ConfirmConversions:=False, _
' ReadOnly:=False, LinkToSource:=True, AddToRecentFiles:=False, _
' PasswordDocument:="", PasswordTemplate:="", WritePasswordDocument:="", _
' WritePasswordTemplate:="", Revert:=False, Format:=wdOpenFormatAuto, _
' Connection:="QUERY qryEmployeeLetters", SQLStatement:= _
' "SELECT * FROM [qryEmployeeLetters]", SQLStatement1:=""
'
' With ActiveDocument.MailMerge
' .Destination = wdSendToNewDocument
' .Execute
' End With
If gbDEBUG = False Then Exit Sub
AnError:
Call Error_Handle("Doc_MailMerge", msMODULENAME, 1, _
"perform the mail merge")
End Sub
© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited Top