Connecting Tech Pros Worldwide Help | Site Map

restoring default printer

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 13th, 2005, 01:27 PM
sakuragirl1
Guest
 
Posts: n/a
Default restoring default printer

I have vb code that gives a user the option to select the printer for
printing a report. At the end I change the default printer back to what
it was. Unfortunately the code I found is for win9x so it is not
working when restoring the default, and I cannot find anything on what
the XP code is.

Win9x code is: Call SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0,
ByVal "windows")

Does anyone know what it is for XP?


  #2  
Old November 13th, 2005, 01:27 PM
Tom van Stiphout
Guest
 
Posts: n/a
Default Re: restoring default printer

On 6 Sep 2005 15:07:54 -0700, "sakuragirl1" <sakuragirl1@yahoo.com>
wrote:

This is NOT the code that changes the printer. Rather, this broadcasts
to all applications that some system setting change has been made.
Apps can listen for such messages, and configure themselves
accordingly.

In Access2002 and up, you may want to look at the new Printer object.

-Tom.

[color=blue]
>I have vb code that gives a user the option to select the printer for
>printing a report. At the end I change the default printer back to what
>it was. Unfortunately the code I found is for win9x so it is not
>working when restoring the default, and I cannot find anything on what
>the XP code is.
>
>Win9x code is: Call SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0,
>ByVal "windows")
>
>Does anyone know what it is for XP?[/color]

  #3  
Old November 13th, 2005, 01:27 PM
Albert D. Kallal
Guest
 
Posts: n/a
Default Re: restoring default printer

yes, my lightweight printer switch code often has this probelm.

You don't mention what version\ of ms-access.

In access 2002 and later, there is a built in printer object, and it lets
you switch the printer with ease.

You can use:

Set Application.Printer = Application.Printers("HP LaserJet Series II")

The above means you don't need my code.

So, to save/switch, you can use:

dim strDefaultPrinter as string

' get current default printer.
strDefaultPrinter = Application.Printer.DeviceName

' switch to printer of your choice:

Set Application.Printer = Application.Printers("HP LaserJet Series II")

do whatever.

Swtich back.

Set Application.Printer = Application.Printers(strDefaultPrinter)


If you are using a earlier versions, then you can use my lightweight printer
switch code here:

http://www.members.shaw.ca/AlbertKal.../msaccess.html

And, I don't have a good solution to your problem, but if you use acces 2002
or later...it don't matter


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal@msn.com
http://www.members.shaw.ca/AlbertKallal


  #4  
Old November 13th, 2005, 01:28 PM
sakuragirl1
Guest
 
Posts: n/a
Default Re: restoring default printer

Thank you so much for your help. I am using Access 2003, and the
information you provided fixed the issue i was having. If you can't
tell this is one of my first Access projects, and I really appreciate
having a place where I can ask questions, and have them answered! ^_^

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.