Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
|
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 26th, 2004, 05:55 PM
Authorized User
 
Join Date: Apr 2004
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to change the default printer

Is there a way to change the default printer with VB6 code? Thanks in advance.

donrafeal

 
Old April 26th, 2004, 07:11 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

    Dim prt As printer
    For Each prt In Printers
        If prt.DeviceName = "myPrinter" Then
            Set printer = prt
            Exit For
        End If
    Next

Marco
 
Old April 27th, 2004, 03:43 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 231
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Marco's code will not change the system default printer, it will only change the printer that VB will use to print to (and sometimes it won't even do that). If you want to change the systems default printer permanently (as in programmatically going to control panel and setting a different printer as the default printer) then take a look at the Microsoft Knowledge Base Article 266767 'HOWTO: Set Which Printer Is the System Default Printer' available at http://support.microsoft.com/default...b;EN-US;266767.

Regards
Owain Williams
 
Old April 27th, 2004, 07:38 AM
Authorized User
 
Join Date: Apr 2004
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the help everyone. I will give it a try today.

 
Old April 27th, 2004, 11:28 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

yep, you are right Owain. In the original post it was not mentioned the "system" printer, so I just presumed that the question was how to change the default VB printer object. Sorry for that.
Marco

Quote:
quote:Originally posted by owain
 Marco's code will not change the system default printer, it will only change the printer that VB will use to print to (and sometimes it won't even do that). If you want to change the systems default printer permanently (as in programmatically going to control panel and setting a different printer as the default printer) then take a look at the Microsoft Knowledge Base Article 266767 'HOWTO: Set Which Printer Is the System Default Printer' available at http://support.microsoft.com/default...b;EN-US;266767.

Regards
Owain Williams





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to retrive paper sizes of default printer gaurikhot .NET Framework 2.0 0 December 6th, 2008 06:23 AM
Default printer anukagni Access 3 March 21st, 2006 08:10 AM
Function for Finding Default Printer smartgir Classic ASP Basics 0 February 7th, 2005 04:02 PM
Determining what default printer is in VBS/WSH dddane VBScript 1 April 30th, 2004 02:08 PM
Printing with default printer lletnek Beginning VB 6 1 March 4th, 2004 06:26 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.