Hi
My database is filling a Word docs with data using bookmarks. My client
wants one particular document to print using the lower tray which will hav a
special letterhead loaded in it.
Is this possible using the Printer object in Access? If not, is it possible
any other way?
Here is what I have tried but doesn't seem to work (letter prints from
default tray, only one copy prints):
Public Function PrintLetter() As Boolean
Dim objWord As Object, objMergeDoc As Object
Dim varPrinterName As Variant
PrintLetter = False
On Error Resume Next
Set objWord = GetObject(, "Word.Application")
If Err.Number <> 0 Then
Err.Clear
On Error GoTo Err_Handler
Set objWord = CreateObject("Word.Application")
End If
On Error GoTo Err_Handler
varPrinterName = DLookup("PrinterName", "tblConfig", "ConfigID = 0")
objWord.Visible = True
objWord.Activate
Set objMergeDoc = objWord.Documents.Add("c:\test\test.dot")
With objMergeDoc
.Bookmarks("FullName").Select
objWord.Selection.Text = "test"
If objWord.ActivePrinter <> varPrinterName Then
objWord.ActivePrinter = varPrinterName
DoEvents
Printers(varPrinterName).PaperBin = acPRBNLower
Printers(varPrinterName).Copies = 2
DoEvents
objWord.PrintOut
objMergeDoc.Close False
End With
PrintLetter = True
Cleanup:
Set objMergeDoc = Nothing
Set objWord = Nothing
Exit Function
Err_Handler:
MsgBox "Error : " & Err.Description & ", error number " & Err.Number
Resume Cleanup
End Function