Listing Printers in Excel
Yes, I knew that, but when Intellisense brings up the listing of dialogs the
two are right next to each other (I figured if he found one, he knows about
the other). I just don't see how the PrinterSetup will offer any significant
advantage over the regular Print dialog box if it is to the point that the
user has to select the printer (unless maybe you don't want to present the
user w/the option to cancel the print -but I don't think that was the
problem).
Thanks for posting the code, Tom. I will add it to my growing collection.
"Tom Ogilvy" wrote:
OP was using
xlDialogPrint
Lee is suggesting
xlDialogPrinterSetup
Although I agree with Steve on Intent.
Here is something similar to what Michel Pierron suggested in JM\B's link
Sub b()
Dim sConn as String, WshNetwork as Object, i as long
Dim avTmp as String
#If VBA6 Then
avTmp = Split(Excel.ActivePrinter, " ")
#Else
avTmp = Split97(Excel.ActivePrinter, " ")
#End If
sConn = " " & avTmp(UBound(avTmp) - 1) & " "
Set WshNetwork = CreateObject("WScript.Network")
Set oPrinters = WshNetwork.EnumPrinterConnections
For i = 0 To oPrinters.Count - 1 Step 2
Debug.Print oPrinters.Item(i + 1) & _
sConn & oPrinters.Item(i)
Next
End Sub
Function Split97(sStr As String, sdelim As String) As Variant
Split97 = Evaluate("{""" & _
Application.Substitute(sStr, sdelim, """,""") & """}")
End Function
The avTmp part is to get the local version of the word "on" to cater to
international differences and was suggested by KeepItCool
--
Regards,
Tom Ogilvy
"JMB" wrote in message
...
According to the OP
I was hoping to get access to the list of printers then do some
manipulation to find PDF Writer, then choose this printer.
He already knows how to bring up the print dialog boxes as evidenced in
his
original posts.
"Lee Meadowcroft" wrote:
You dont need any of that complicated rubbish, try:
strOldActivePrinter = Application.ActivePrinter
Application.Dialogs(9).Show
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Application.ActivePrinter = strOldActivePrinter
It saves the current printer name, prompts you to select the installed
PDF Printer, Prints and then restores the old printer.
Lee
|