Solved

How to get specific Printer name in Commondialog Name Box

Posted on 2002-05-19
7
208 Views
Last Modified: 2007-12-19
When I launch:
commondialog1.showprinter
how do I get a specific printer name to appear in the
printer NAME box.
?
0
Comment
Question by:rbend
  • 4
  • 2
7 Comments
 
LVL 12

Expert Comment

by:roverm
ID: 7019523
Hi (again)!

I found a very good article about setting the default printer:

http://www.freevbcode.com/ShowCode.Asp?ID=641

This is also a good solution for your other question, I will post it there as well.

It uses the ini file to change the default printer and broadcasts the change to all applications.

D'Mzzl!
RoverM
0
 

Author Comment

by:rbend
ID: 7019717
roverm:
The code you sited does change the default printer. That's good. But it does not tell me what the original printer was. Therefore, I can't change it back.
0
 
LVL 12

Expert Comment

by:roverm
ID: 7019731
Yep you can!
You can alter the class module to read the default printer first.
I will take a look also. "I'll be back..." ;-)

D'Mzzl!
RoverM
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 12

Accepted Solution

by:
roverm earned 50 total points
ID: 7019733
*lol*

Some easy code to read the current printer:

Public Function GetCurrentPrinter() As String
Dim curPrinter As Printer
   
    Set curPrinter = Printer
    Debug.Print curPrinter.DeviceName
    GetCurrentPrinter = curPrinter.DeviceName
   
    Set curPrinter = Nothing
End Function

D'Mzzl!
RoverM
0
 
LVL 9

Expert Comment

by:Valliappan AN
ID: 7020952
Well, thats a good link, which hope, I have been using for some time, to change the default printer.

BTW, In case of Commondialog, you could have a look at this:
http://www.devx.com/premier/mgznarch/getstarted/1999/gs299/psgs299.pdf

It states, you set TrackDefault property to True, gets the defa. printer name to Common dialog. Setting it to false, gets the recently used printer. Also, PrinterDefault property set to True makes the selected printer to default printer, if I understood right.

Hope it helps,
Cheers.
0
 

Author Comment

by:rbend
ID: 7021585
you worked hard and covered my need.
Thanks
0
 
LVL 12

Expert Comment

by:roverm
ID: 7021973
Thanks!

D'Mzzl!
RoverM
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question