Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Available printers in a dropdown-combolist?

Hello,

help needed please :-)

For my current application, I would like the user to be able to select
which printer to use in a userform combolist.

The code should loop to find all available printers, and set the
user-selected one to be active.

Thank you in advance!



Best regards,
-Nortor

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default Available printers in a dropdown-combolist?

NorTor,

Randy Birch has some code at his site www.mvps.org/vbnet which gets all
printers. Look for topic 'Enumerating Local and Network Printers'. It just
gets a list, you will need to load your dropdown from the data returned.

--

HTH

Bob Phillips

"NorTor" wrote in message
...
Hello,

help needed please :-)

For my current application, I would like the user to be able to select
which printer to use in a userform combolist.

The code should loop to find all available printers, and set the
user-selected one to be active.

Thank you in advance!



Best regards,
-Nortor



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Available printers in a dropdown-combolist?

I'd let Excel do the work for you. there is an old built-in Printer Setup
dialog that when displayed let's the user change the printer as well as
printer settings. Rather than look through a list of printers and place them
in a listbox/dropdown, I'd simply show the Printer Setup dialog. In the set
of userform routines below, I use a label (lblCurrentPrinter) to display the
current printer. The userform has a command button called cmdPrinter
(labeled "Printer..." on the userform) that when clicked displays the
built-in Printer Setup dialog. If a change is made in that dialog,
lblCurrentPrinter is updated to show the new printer.

I've placed comments in with the code to explain what the userform is
doing...

'Routine that automatically fires when this Userform gets loaded into memory
Private Sub UserForm_Initialize()
'Display the current printer name (and if on a network its network path)
' in a label in this userform
Me.lblCurrentPrinter = Application.ActivePrinter
End Sub

'OK button in the userform
Private Sub cmdOK_Click()
'Hide the userform and removes it from memory
Unload Me
End Sub

'"Printer..." button on Userform
Private Sub cmdPrinter_Click()
'Hide the userform
Me.Hide
'Use a bChangePrinter() function to display the built-in Printer Setup
dialog
' and determine whether a new printer was selected. If a new printer,
update the label
' in the userform to show the current printer
If bChangePrinter() Then Me.lblCurrentPrinter =
Application.ActivePrinter
'Show this userform again
Me.Show
End Sub

'Shows the built-in Printer Setup Dialog and determines if a printer change
was made
Function bChangePrinter()

Dim bChange As Boolean

On Error GoTo Error

'Assume the user will not change the printer
bChange = False

'Show the built-in dialog
'If the user clicks the OK button in the built-in dialog, bChange will
return True
'If the user clicks the Cancel button in the built-in dialog, bChange
will return False
bChange = Application.Dialogs(xlDialogPrinterSetup).Show

Cleanup:

'Pass the results of the built-in dialog to the function's True/False
setting
bChangePrinter = bChange

Exit Function
Error:
MsgBox Err.Number & vbLf & vbLf & Err.Description, vbCritical,
"bChangePrinter"
Resume Cleanup
End Function



--
________________________
Robert Rosenberg
R-COR Consulting Services
Microsoft MVP - Excel

"NorTor" wrote in message
...
Hello,

help needed please :-)

For my current application, I would like the user to be able to select
which printer to use in a userform combolist.

The code should loop to find all available printers, and set the
user-selected one to be active.

Thank you in advance!



Best regards,
-Nortor



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
LABEL PRINTERS CFAVRE Excel Discussion (Misc queries) 0 August 4th 08 05:06 PM
Printing on different printers (makes/models etc) Chuckee Excel Discussion (Misc queries) 1 February 23rd 07 03:52 PM
2 printers 1 does not print name in same spot Cuppa T Excel Discussion (Misc queries) 0 July 22nd 06 03:51 AM
Excel cannot find printers coopercat Excel Discussion (Misc queries) 0 November 30th 05 05:17 PM
List of available printers prizm1 New Users to Excel 3 June 12th 05 01:32 PM


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

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

About Us

"It's about Microsoft Excel"