Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default How do I determine the Acrobat Distiller codename?

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default How do I determine the Acrobat Distiller codename?

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





"Jeremy Gollehon" wrote:

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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default How do I determine the Acrobat Distiller codename?

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."

keepitcool wrote:
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

"Jeremy Gollehon" wrote:

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





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
string to codename rk0909 Excel Discussion (Misc queries) 4 September 25th 08 10:57 PM
how to re install Adobe Acrobat in Excel? The adobe Acrobat work. Execl error Excel Discussion (Misc queries) 1 March 17th 05 02:29 AM
How do I auto-save multipage report printing to Acrobat Distiller sbutler96 Excel Discussion (Misc queries) 1 March 9th 05 04:15 AM
How to detect Acrobat Distiller open Heiko Excel Programming 1 August 6th 03 02:27 AM
How to detect Acrobat Distiller open Bill Li Excel Programming 0 August 6th 03 02:25 AM


All times are GMT +1. The time now is 09:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"