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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataReport Printer

Status
Not open for further replies.

L0stAngel

Programmer
May 5, 2005
58
US
Hello, I have a report that when printed, must print to a certain printer on the network (//network/PDFPrinter). This printer is NOT the default printer on the computer. I would like it, that when my report loads, I want it to print that report automatically to //network/PDFPrinter without having to select it from the Printer Dialog. How can I do this?
 
A quick search for 'set printer' found this:
thread222-915800
which should get you started. The search also turns up several other suggestions

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first
'If we're supposed to work in Hex, why have we only got A fingers?'
Essex Steam UK for steam enthusiasts
 
I tried the following code I found, but it will not work.

Code:
Dim p As VB.Printer
For Each p In VB.Printers
If p.DeviceName = "PDFCreator" Then
'Set Printer = p
End If

Next

Me.PrintReport False, rptRangeAllPages

In the above code, shouldn't it cycle through the printers until the devicename = "PDFCreator", then if it's found, it sets the default printer to PDFCreator and prints?
 
You appear to have remmed out the active line - or is that just a typo?

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first
'If we're supposed to work in Hex, why have we only got A fingers?'
Essex Steam UK for steam enthusiasts
 
You might have to use the Printers collection. Something like this:

Code:
Dim i as integer

for i=0 to Printers.Count-1
   if Printers(i).DeviceName="PDF Creator" then
      Set Printer=Printers(i)
   endif
next i

Printer is the name of the default printer, so if you change it, it will apply to the rest of your printing jobs untill you assign it again.

Is "PDF Creator" the full device name? On my computer, the Acrobat printer has a different device name (maybe it's due to the Acrobat version on your machine and mine).

I hope this helps!
 
Thanks all, I figured out my problem. In my report_Initialize, I added

Code:
Dim w As New WshNetwork
w.SetDefaultPrinter ("PDFCreator")

Me.PrintReport False, rptRangeAllPages

And in report_terminate I added:

Code:
Dim w As New WshNetwork
w.SetDefaultPrinter ("HP5000n")
Set w = Nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top