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

Dialog to select a printer... 2

Status
Not open for further replies.

Paco75

Programmer
Oct 11, 2001
239
US
Hi,

I want to put a dialog box to select a printer in my excel macro... it must return the printer name (like //MyServer/ThePrinter) Does anyone knows?

thanks
 
I found a way to do so... I'm not sure it's the best one but it works... here it is:

'Pop-up a dialog to select a printer
Application.Dialogs(xlDialogPrinterSetup).Show

'Get the active printer name (the one selected in dialog)
printerName = Application.ActivePrinter

'Remove the last extra chars to leave only
'the //Server/Printer in the printerName
Y = InStr(printerName, " ")
If Y = 0 Then
Y = 1
End If
printerName = Mid(printerName, 1, Y - 1)

'Send the .srq file to the printer
Shell (&quot;cmd /C &quot;&quot;copy &quot;&quot;&quot; + <file path and name> + &quot;&quot;&quot; &quot; + printerName + &quot;&quot;&quot;&quot;)

Hope it helps someone! Bye [wavey]
 
Cool! I've never come across that dialog in normal interactions with Excel. Looks like something Bill put in for the benefit of VBA programmers :)

Rob
[flowerface]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top