Question : Access 2003/Excel 2003 - looping thru the printers object

Hi EE,

I found this related post, and adapted it for my purposes.
Adobe Acrobat PRO is installed differently on each of our pc's.

I have mdb that behaves like a script, by being evoked by Windows Scheduler thru a bat file.

I am going away for a few days, would like to disable the script on my pc, and ask a colleague to run it manually.
My script failed, bec have hardcoded:

 objExcel.ActivePrinter = "Adobe PDF on LPT2:"

and his is:
"Adobe PDF on ne05"

so copied your ideas to do this:

Dim p              As Printer
Dim strPrinterName As String
Dim lngCount       As Long


For Each p In Printers
   Debug.Print p.DeviceName & " "; p.Port
   
   lngPos = InStr(1, p.DeviceName, "Adobe")
   If lngPos > 0 Then
      objExcel.ActivePrinter = p.DeviceName
      Exit For
   End If
   
Next

However, this line is faling
             objExcel.ActivePrinter = p.DeviceName

bec. it does not recognize printer of: "Adobe Acrobat"
it's looking for the full name of:


"Adobe PDF on LPT2:"

i did a debug.print on p.port, but it shows an ip address, and don't know how to use this in VBA.

below is a screen shot:

pls advise,
tx for your ideas and help,
sandra

Answer : Access 2003/Excel 2003 - looping thru the printers object

Hi Sandra:

Here are the couple of examples I found online.....you can give it a shot....

http://www.dailydoseofexcel.com/archives/2008/04/05/getting-the-printer-port/


Other one is example in excel file...


I haven't looked in details.....but I think this might be able to help you...it gets the printer information from registry
 
Printing Example
 
Random Solutions  
 
programming4us programming4us