Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print a word document from access to a specific printer 2

Status
Not open for further replies.

xyle

Programmer
Jul 2, 2003
23
US
My program works fine opening up a word document, filling in the formsfields and printing out the document. Is there as way to have it go to specific printer that is not the default printer? Here the code if needed.

Code:
Dim oWord As Object         ' <-- Microsoft Word

Const DOC_PATH = "S:\Access Data\Special Taxes\"
Const DOC_TAX_RECEIPT = "ManualBill.doc"


Set oWord = CreateObject("Word.Application")
oWord.Documents.Open Filename:=DOC_PATH & DOC_TAX_RECEIPT
oWord.Options.PrintBackground = False

With oWord.ActiveDocument
    .FormFields("txtAcctNum").Result = txtAcctNum
    
     'several more FormFields 

    .Saved = True     ' <-- Used to prevent "Do you want to save" dialog
    .PrintOut
    .Close
End With
 
Code:
dim activePrinterTxt as string
Dim oWord As Object         ' <-- Microsoft Word

Const DOC_PATH = "S:\Access Data\Special Taxes\"
Const DOC_TAX_RECEIPT = "ManualBill.doc"


Set oWord = CreateObject("Word.Application")
oWord.Documents.Open Filename:=DOC_PATH & DOC_TAX_RECEIPT
oWord.Options.PrintBackground = False

With oWord.ActiveDocument
    .FormFields("txtAcctNum").Result = txtAcctNum
    
     'several more FormFields 

    .Saved = True     ' <-- Used to prevent "Do you want to save" dialog
     activePrinterTxt=oWord .ActivePrinter
     oWord.ActivePrinter="new printer name"
    .PrintOut
     oWord.ActivePrinter=activePrinterTxt
    .Close
End With
 
Knew it was going to be something simple like that
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top