• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 146
  • Last Modified:

printing in VB

how can I let a user select a printer without changing the default printer in the windows system control.
0
jackg
Asked:
jackg
  • 3
1 Solution
 
mcriderCommented:
First look at this microsoft KB article:

HOWTO: Retrieve Printer Name from Windows 95/98 Registry in VB
http://support.microsoft.com/support/kb/articles/q143/2/74.asp?LNG=ENG&SA=MSDN 
 
It talks about how to get the default printer name out of the registry... You want to save off the name of the printer that's in that key, then change the printer to another printer and use the other printer...

When you're ready to put the original default printer back, you need to write the name of the default printer back to the registry... to do that, take a look at this microsoft KB article:

HOWTO: Use the Registry API to Save and Retrieve Setting
http://support.microsoft.com/support/kb/articles/q145/6/79.asp?LNG=ENG&SA=MSDN 


By the way, you posted this question twice... go close the other question. It is http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=10266846 


Cheers!


Cheers!

0
 
jackgAuthor Commented:
mcrider, thanks for that but I do not want to change the registry as the user wants to use their default printer in other apps. If they open another app then use what they think is the default printer for that app the system will still be using the one set in VB. What I really want is to let them select a printer which is specific to my app and does not affect the system control.
0
 
mcriderCommented:
Don't use the CommonDialog to select the printer... It will set whatever printer is selected as the default printer... Do it yourself... for example:

Populate a listbox like this:

   Dim X As Printer
   For Each X In Printers
       List1.AddItem X.DeviceName
   Next


Then put this in the listbox double-click event...

    For Each X In Printers
        If X.DeviceName = List1.List(List1.ListIndex) Then
            Set Printer = X
            Exit For
        End If
    Next



VB will then use whatever printer was double-clicked on when you use the Printer Object....


Cheers!
0
 
InformativeCommented:
Not only does common dialog change the default but often does NOT redirect the print to the newly selected printer for some reason too!  After I changed the printer to the new choice then printed something it still went to the old default printer and when I exited and printed from someplace else I noticed that the selected printer from earlier was now the default THEN IT decided it was time to start using the selected printer hehehe.  What trash!  

Whats even scarier is how unlikely it is Microsoft will even bother to fix the common dialog to work as expected..
0
 
mcriderCommented:
Thanks for the points! Glad I could help!


Cheers!
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now