Results 1 to 6 of 6

Thread: [RESOLVED] Selecting Default Printer in Control Panel

  1. #1

    Thread Starter
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,236

    Resolved [RESOLVED] Selecting Default Printer in Control Panel

    Ok guys/gals.

    Now I've made apps for a number of years for work. Now some of these allow the user to print some data out. Rather than using a CommonDialog (which means an extra control) so they can select which printer, I've always printed to the default printer which isn't a problem. Now on our college network we can have 10 printers on each computer. Now if the user sets up the default printer they want to use then no problem, but they don't.

    Now on Win9x/ME I can use

    Call Shell("rundll32.exe shell32.dll,Control_RunDLL main.cpl @2", 1)

    without a problem. This will show the printers in Control Panel and they can just right-click and set as default. I can't get this to work on Win2k/XP. It doesn't even show any errors. Does anyone know the correct code for showing the printers on WinNT. I've search this forum but no obvious answer comes back.

    Thanks.
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Selecting Default Printer in Control Panel

    For Win2K/XP try this:
    Code:
    Private Sub Command1_Click()
    Dim shellCommand As String
    
        shellCommand = "rundll32.exe shell32.dll,SHHelpShortcuts_RunDLL PrintersFolder"
        Shell shellCommand, vbNormalFocus
    
    End Sub
    I don't have WinNT4 so I can't test but I think your command should work on NT4 system.

  3. #3
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: Selecting Default Printer in Control Panel

    Quote Originally Posted by RhinoBull
    For Win2K/XP try this:
    Code:
    Private Sub Command1_Click()
    Dim shellCommand As String
    
        shellCommand = "rundll32.exe shell32.dll,SHHelpShortcuts_RunDLL PrintersFolder"
        Shell Command, vbNormalFocus
    
    End Sub

    Shouldn't that be, Shell shellCommand, vbNormalFocus

  4. #4

  5. #5

    Thread Starter
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,236

    Re: Selecting Default Printer in Control Panel

    Quote Originally Posted by RhinoBull
    For Win2K/XP try this:
    Code:
    Private Sub Command1_Click()
    Dim shellCommand As String
    
        shellCommand = "rundll32.exe shell32.dll,SHHelpShortcuts_RunDLL PrintersFolder"
        Shell shellCommand, vbNormalFocus
    
    End Sub
    Thank you RhinoBull I will make a simple app and try it out tomorrow. I haven't bothered with the shellCommand no point I've just use.

    Shell "rundll32.exe shell32.dll,SHHelpShortcuts_RunDLL PrintersFolder", vbNormalFocus

    I works perfect on Win98SE just the same as my last code did so it should work on WinXP. I called it WinNT because most system are either Win2k. WinXP or Vista so they are all NT, sorry for calling them all NT.

    Thanks again.
    Last edited by Keithuk; Dec 8th, 2008 at 07:20 AM.
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

  6. #6

    Thread Starter
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,236

    Re: Selecting Default Printer in Control Panel

    Thanks RhinoBull it works great, topic [Resolved]
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width