VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Change selected printer

by Duncan Jones (19 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (11 Votes)

Temporarily change the currently selected (default) printer within your VB program

Assumes
This doesn't save the change to the registry - which needs to be done for a permanent change of default printer.
API Declarations
n/a

Rate Change selected printer

Public Function SetDefaultPrinter(ByVal DeviceName As String) As Boolean
Dim prThis As Printer
If Printers.Count > 0 Then
  '\\ Iterate through all the installed printers
  For Each prThis In Printers
    '\\ If the desired one is found
    If prThis.DeviceName = DeviceName Then
      Set Printer = prThis
      SetDefaultPrinter = True
      '\\ Stop searching
      Exit For
    End If
  Next prThis
End If
End Function

Download this snippet    Add to My Saved Code

Change selected printer Comments

No comments have been posted about Change selected printer. Why not be the first to post a comment about Change selected printer.

Post your comment

Subject:
Message:
0/1000 characters