Selecting a printer from a combobox? 
Author Message
 Selecting a printer from a combobox?

Hello

I have a user form with 3txt fields, 1cmdPrint button and 1 cmdclose button.

I also want a combo box that shows all installed printers on a (NT4)
computer. I want the default printer to be default in the combo box but if
users want to print to another installed printer they should have the
opportunity to select the printer they want to print to.
Is this possible?

TUA!
Ole-P
(Norway)



Wed, 17 Sep 2003 19:47:51 GMT  
 Selecting a printer from a combobox?
Hi Ole-P

Take a look at the following article

How can I get a list of the available printer names?
http://www.mvps.org/word/FAQs/MacrosVBA/AvailablePrinters.htm

Once you have the list in the Variant, as described in the article, you can
load it into a ListBox or ComboBox by means of the List property.

--
Regards
Jonathan West - Word MVP
MultiLinker - Automated generation of hyperlinks in Word
Conversion to PDF & HTML
http://www.multilinker.com
Word FAQs at http://www.multilinker.com/wordfaq
Please post any follow-up in the newsgroup. I do not reply to Word questions
by email


Quote:
> Hello

> I have a user form with 3txt fields, 1cmdPrint button and 1 cmdclose
button.

> I also want a combo box that shows all installed printers on a (NT4)
> computer. I want the default printer to be default in the combo box but if
> users want to print to another installed printer they should have the
> opportunity to select the printer they want to print to.
> Is this possible?

> TUA!
> Ole-P
> (Norway)



Thu, 18 Sep 2003 19:18:02 GMT  
 Selecting a printer from a combobox?

Quote:
> How can I get a list of the available printer names?
> http://www.mvps.org/word/FAQs/MacrosVBA/AvailablePrinters.htm

> Once you have the list in the Variant, as described in the article, you
can
> load it into a ListBox or ComboBox by means of the List property.

I pasted the code into a new module but i'm not sure how i should load it
into a Combobox ?

Thx
Ole-P (Learning VBA and it's Fun!;-))



Fri, 19 Sep 2003 02:42:52 GMT  
 Selecting a printer from a combobox?
Hi Ole,

ComboBox1.List = ListPrinters()

should do the trick.

--
Regards
Jonathan West - Word MVP
MultiLinker - Automated generation of hyperlinks in Word
Conversion to PDF & HTML
http://www.multilinker.com
Word FAQs at http://www.multilinker.com/wordfaq
Please post any follow-up in the newsgroup. I do not reply to Word questions
by email


Quote:
> > How can I get a list of the available printer names?
> > http://www.mvps.org/word/FAQs/MacrosVBA/AvailablePrinters.htm

> > Once you have the list in the Variant, as described in the article, you
> can
> > load it into a ListBox or ComboBox by means of the List property.

> I pasted the code into a new module but i'm not sure how i should load it
> into a Combobox ?

> Thx
> Ole-P (Learning VBA and it's Fun!;-))



Fri, 19 Sep 2003 06:20:39 GMT  
 Selecting a printer from a combobox?

Quote:
> ComboBox1.List = ListPrinters()
> should do the trick.

Thank you for helping me out here!
I still have some questions ;-)

How could I assign it to a print button (cmdprint)?
Example:
If user clicks print then print to the default printer. If user selects a
printer from the combo box then print to the selected printer.
Is it also possible to show the default printer as default in the combo box?
(Well I guess that nothing is impossible, right?)

Thanks for all help!!!!
Regards
Ole-Petter



Sat, 20 Sep 2003 18:04:48 GMT  
 Selecting a printer from a combobox?
Hi Ole,


Quote:
> > ComboBox1.List = ListPrinters()
> > should do the trick.

> Thank you for helping me out here!
> I still have some questions ;-)

> How could I assign it to a print button (cmdprint)?
> Example:
> If user clicks print then print to the default printer. If user selects a
> printer from the combo box then print to the selected printer.

OK, suppose you have a Listbox called PrinterList, and it has your list of
printers, and you have selected the printer you want to use.

Put the following code into the Click event of cmdPrint

Sub cmdPrint_Click()
Dim strOldPrinter as String
strOldPrinter = ActivePrinter
ActivePrinter = PrinterList.Text
ActiveDocument.PrintOut Background:=False
ActivePrinter = strOldPrinter
End Sub

Quote:
> Is it also possible to show the default printer as default in the combo
box?
> (Well I guess that nothing is impossible, right?)

Yes this can be done as well. Put the following into the Initialize event of
the UserForm

Dim vPrinters as Variant
Dim i As Long

vPrinters = ListPrinters()
PrinterList.List = vPrinters
For i = 0 to UBound(vPrinters)
    If Left$(ActivePrinter, Len(vPrinters(i))) = vPrinters(i) Then
        PrinterList.ListIndex = i
        Exit For
    End If
Next i

--
Regards
Jonathan West - Word MVP
MultiLinker - Automated generation of hyperlinks in Word
Conversion to PDF & HTML
http://www.multilinker.com
Word FAQs at http://www.multilinker.com/wordfaq
Please post any follow-up in the newsgroup. I do not reply to Word questions
by email



Sat, 20 Sep 2003 20:01:16 GMT  
 Selecting a printer from a combobox?
Big thanks to you Jonathan!
Now it's perfect.

Best regards
Ole



Sun, 21 Sep 2003 02:04:03 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. selecting a printer with a combobox?

2. Selecting printer from ComboBox

3. Add PaperSource of a selected printer to the combobox

4. Q: Printing report on non-default printer w/o user selecting printer

5. Macro that selects printer and prints doc also changes default printer

6. How to select a printer out of the printers collection

7. How I can select a printer like defauld printer without using CommonDialog Control

8. How do I find printer selected from the Printer Dialog Box

9. Select Printer from List of Network Printers, How?

10. Select item in combobox using VB

11. Activating a combobox with a selected item from another cbo

12. Which property is changed for combobox select?

 

 
Powered by phpBB® Forum Software