Results 1 to 3 of 3
  1. #1
    trevor40's Avatar
    trevor40 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Feb 2014
    Location
    Australia
    Posts
    407

    Printer Selection in VBA code

    Hi is there an easy way to select the printer to be used? I'm hoping that I can use the printer name from windows.

  2. #2
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Here's some code that went through one of the forums recently. Some of it might be helpful.
    Its purpose was to change the default printer.

    Code:
    '
    MVP MCC: Content Creator - "HansV MVP"
    'You should be able to do something like this:
    
     Sub SwitchPrinter()
         Dim prt As Printer
         ' Get current default printer
         Set prt = Application.Printer
         Debug.Print "Current default " & prt.devicename
         ' Set default printer
         Application.Printer = Application.Printers("OtherPrinter")
          ' Print something, e.g.
         DoCmd.PrintOut  AnySmallTableName here
         Debug.print "Switched to " &  Application.Printer.deviceName
         ' Restore original printer
         Set Application.Printer = prt
         debug.print "Restored to " &  prt.devicename
     End Sub
    
    'where OtherPrinter is the name of the required printer. 
    '
    'To list the names of available printers, run the following code:
    
    
    Sub ListPrinters()
         Dim prt As Printer
         For Each prt In Printers
             Debug.Print prt.DeviceName
         Next prt
     End Sub
    
    'The printer names will be listed in the Immediate window (press Ctrl+G to
    activate this window).

  3. #3
    trevor40's Avatar
    trevor40 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Feb 2014
    Location
    Australia
    Posts
    407
    Yhanks for that I'll see how I can adapt it and continue.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 02-25-2014, 11:46 AM
  2. Choose Printer Tray with a VBA Code
    By vinchi1974 in forum Programming
    Replies: 1
    Last Post: 08-03-2012, 12:24 AM
  3. Trying to Change Default printer
    By sims.anderson2010 in forum Programming
    Replies: 2
    Last Post: 03-08-2012, 08:07 AM
  4. Replies: 2
    Last Post: 01-06-2012, 09:42 AM
  5. Forms to Printer
    By Roland in forum Reports
    Replies: 1
    Last Post: 11-22-2010, 10:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums