How do I determine the Acrobat Distiller codename?

J

Jeremy Gollehon

I'm trying to set the Acrobat Distiller as the default printer in code. The
problem I'm running into is that distiller has a different codename on
different computers.

Eg.- On my computer it's Application.ActivePrinter = "Acrobat Distiller on
Ne01"
On another system, its Application.ActivePrinter = "Acrobat
Distiller on Ne02"

Is there a way to establish a variable like DistillerName = %Distiller% ????

Then I could run the code:
Application.ActivePrinter = DistillerName

Application.ActivePrinter = "Acrobat Distiller" does not work.

It would also be great if anyone knew how to get the code name of the
current active printer so I could put it back when I'm done.

Thanks!
-Jeremy
 
K

keepitcool

Jeremy,

I posted the the more general PrinterList function a while back...

It works on Xl2k or newer (due to use of the split function.)
But it will work on international installs, where the ON string is
different.

The PrinterList Function will give you an array of all your printers.
in the correct Excel syntax.

Then (just for you :) I included the getDistiller
loop to make it simply

application.activeprinter=getdistiller


Suc6!

keepITcool

< email : keepitcool chello nl (with @ and .) >
< homepage: http://members.chello.nl/keepitcool >



Option Explicit

Private Declare Function GetProfileString Lib "kernel32" _
Alias "GetProfileStringA" _
(ByVal lpAppName As String, ByVal lpKeyName As String, _
ByVal lpDefault As String, ByVal lpReturnedString As String, _
ByVal nSize As Long) As Long

Function GetDistiller() as string
Dim pl, i%
pl = PrinterList
For i = LBound(pl) To UBound(pl)
If LCase(pl(i)) Like "*distiller*" Then
GetDistiller = pl(i)
Exit For
End If
Next
End Function


Function PrinterList()
Dim lRet As Long
Dim sBuffer As String
Dim lSize As Long
Dim avTmp As Variant
Dim aPrn() As String
Dim n%, sPrn$, sConn$, sPort$

'Get localized Connection string
avTmp = Split(Excel.ActivePrinter)
sConn = " " & avTmp(UBound(avTmp) - 1) & " "

'Get Printers
lSize = 1024
sBuffer = Space(lSize)
lRet = GetProfileString("devices", vbNullString, vbNullString, _
sBuffer, lSize)
sBuffer = Left(sBuffer, lRet)
avTmp = Split(sBuffer, Chr(0))

'Get Ports
ReDim Preserve avTmp(UBound(avTmp) - 1)
For n = 0 To UBound(avTmp)
sBuffer = Space(128)
lRet = GetProfileString("devices", avTmp(n), vbNullString, _
sBuffer, 128)
sPort = Mid(sBuffer, InStr(sBuffer, ",") + 1, _
lRet - InStr(sBuffer, ","))
avTmp(n) = avTmp(n) & sConn & sPort
Next
PrinterList = avTmp
End Function
 
J

Jeremy Gollehon

keepITcool,

Thanks for the help! Very cool.

I did need to make a change to the GetDistiller function though. There
needed to be asterisks around the word "distiller" for it to work the way
you posted, however, I actually went with the Instr function instead.

----------------------------------------------
Function GetDistiller() As String
Dim pl, i%
pl = PrinterList
For i = LBound(pl) To UBound(pl)
If InStr(pl(i), "Distiller") > 0 Then
' If LCase(pl(i)) Like "*distiller*" Then
GetDistiller = pl(i)
Exit For
End If
Next
End Function
----------------------------------------------

I'm sure you only missed this because you threw that function together
quickly just for me. :) Thanks!

-Jeremy

P.S.- I like you philosophy.
"Keep it simple but flexible and make it look good."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top