I'm having trouble setting the printer for Word in VB 6. If I were to print an Excel sheet, I'll do:
Dim excel_app As Excel.Application
excel_app.ActiveWorkbook.PrintOut Copies:=prnjob.numPages, ActivePrinter:=prnjob.strPrinter
excel_app.Wait (Now + TimeValue("0:00:3")) ' Wait
were prnjob is a simple UDT that stores users print preferences, but:
Since here's no ActivePrinter property for word_app.PrintOut I've tried:
Dim wordApp As Word.Application
Dim wordDoc As Word.Document
' Try to set default printer
Dim prtDev As Object
For Each prtDev In Printers
If prtDev.DeviceName = prnjob.strPrinter Then
Set Printer = prtDev
I've to say that I don't have a printer attached to the PC (it's broken), instead I use Adobe distiller and Microsoft Fax for testing. This works perfectly in excel, but word always prints to it's default printer (Adobe).
Also, there's no wait procedure for word objects (not that I'm happy with the excel code, but that works). So How do I make sure printing is
finnished before I destroy the object?
Last, but not least. My process list still shows Word (and sometime excel) even that I do:
excel_app.ActiveWorkbook.Close False ' Close the workbook without saving. (If true will ask for filename)
Set wordDoc = Nothing ' wordDoc = wordApp.ActiveDocument
Set wordApp = Nothing
Why this doesn't kill them?
I'll be happy with docs/links and I would really appreciate some working code.