Getting default printer name from Printers Collection 
Author Message
 Getting default printer name from Printers Collection

Is there a way to identify which is the
default printer by using the Printers collection?
Graham



Fri, 10 Nov 2000 03:00:00 GMT  
 Getting default printer name from Printers Collection

Quote:

>Is there a way to identify which is the
>default printer by using the Printers collection?
>Graham

Hi Graham,

this is from VB's help file:

The following code searches all available printers to locate the first
printer with its page orientation set to portrait, then sets it as the
default printer:
Dim X As Printer
For Each X In Printers
 If X.Orientation = vbPRORPortrait Then
  ' Set printer as system default.
  Set Printer = X
  ' Stop looking for a printer.
  Exit For
 End If
Next

The object "Printer" is obviously always the default printer (please correct
me, anybody, if I'm missing out on something). You can check in the Printers
collection, the printer object (as above) X = Printer would be the default
printer. The property DeviceName is probably what you're looking for. Check
if it works because I might be wrong...



Fri, 10 Nov 2000 03:00:00 GMT  
 Getting default printer name from Printers Collection

Bill,
Thanks for the reply.
Your code finds the FIRST printer having
portrait orientation, not the current default printer

Graham
-------------------------------

Quote:


> >Is there a way to identify which is the
> >default printer by using the Printers collection?
> >Graham

> Hi Graham,

> this is from VB's help file:

> The following code searches all available printers to locate the first
> printer with its page orientation set to portrait, then sets it as the
> default printer:
> Dim X As Printer
> For Each X In Printers
>  If X.Orientation = vbPRORPortrait Then
>   ' Set printer as system default.
>   Set Printer = X
>   ' Stop looking for a printer.
>   Exit For
>  End If
> Next

> The object "Printer" is obviously always the default printer (please correct
> me, anybody, if I'm missing out on something). You can check in the Printers
> collection, the printer object (as above) X = Printer would be the default
> printer. The property DeviceName is probably what you're looking for. Check
> if it works because I might be wrong...



Sat, 11 Nov 2000 03:00:00 GMT  
 Getting default printer name from Printers Collection

Just found that this does it ........
PR = Printer.DeviceName
Graham
----------------

Quote:

> Is there a way to identify which is the
> default printer by using the Printers collection?
> Graham



Sun, 12 Nov 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Getting the name of the default printer

2. Changing Printers property reset printer to Windows default printer

3. Macro to change default printer and then restore original default printer settin

4. printer default to non-default printer

5. Changing Printer names (displayed names in printer folder)

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

7. VBA: Printer Object / Printer Collection

8. No printer in Printer Collection

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

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

11. Problem setting the active printer of Word 97 without changing the Windows default printer

12. andere printer printen, dan terug naar default printer

 

 
Powered by phpBB® Forum Software