Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-04-2018, 09:24 AM
JennyWaley JennyWaley is offline Print settings used based on active printer Windows 10 Print settings used based on active printer Office 2016
Novice
Print settings used based on active printer
 
Join Date: Oct 2018
Posts: 2
JennyWaley is on a distinguished road
Default Print settings used based on active printer


Once I can get past this, I am sure I can get the rest of the Macros to work which have different function based upon the choice.

For all our printers, Tray 1 is the envelope feeder, Tray 2 is letterhead, Tray 3 is Bond and Tray 4 is plain and tray 5 is manual feed.

I have a macro that I used in 2010 that I cannot get the vba to work in 2016 word. It bypasses and goes to the "else" at the end. I think it is not understanding how to read the current active printer. All the macros I am seeing for printing go to change the active printer. I think it may be related to the WordBasic command at the top.

This works fine in 2010:
No matter what I do, it is printing to the tray 4 which is plain paper for the printers which are listed by a code (xerox) and Tray 3 only (bond) for the other type of printer.

Code:
Sub whichprinter()
Dim defprinter As String

defprinter = Mid(ActivePrinter, 1, 20)
WordBasic.Insert defprinter
End Sub

Sub PrintLetterhead()
Dim defprinter As String

defprinter = Mid(ActivePrinter, 1, 20)
Select Case defprinter
    Case "\\GS-DC2\MFP1"
    With ActiveDocument.PageSetup
        .FirstPageTray = 260
        .OtherPagesTray = 259
    End With
    GoTo PrintDoc
    Case "\\GS-DC2\MFP2"
    With ActiveDocument.PageSetup
        .FirstPageTray = 260
        .OtherPagesTray = 259
    End With
    GoTo PrintDoc
    Case "\\GS-DC2\MFP3"
    With ActiveDocument.PageSetup
        .FirstPageTray = 260
        .OtherPagesTray = 259
    End With
    GoTo PrintDoc
      Case "\\GS-DC2\MFP4"
    With ActiveDocument.PageSetup
        .FirstPageTray = 260
        .OtherPagesTray = 259
    End With
    GoTo PrintDoc
    Case "\\GS-DC2\MFP5"
    With ActiveDocument.PageSetup
        .FirstPageTray = wdPrinterMiddleBin
        .OtherPagesTray = wdPrinterLowerBin
    End With
     Case "\\GS-DC2\MFP6"
    With ActiveDocument.PageSetup
        .FirstPageTray = wdPrinterMiddleBin
        .OtherPagesTray = wdPrinterLowerBin
    End With
    GoTo PrintDoc
    Case "Bookkeeping Xerox WorkCentre Pro 5335"
    With ActiveDocument.PageSetup
        .FirstPageTray = 260
        .OtherPagesTray = 259
    End With
    GoTo PrintDoc
    Case Else
    With ActiveDocument.PageSetup
        .FirstPageTray = 258
        .OtherPagesTray = 259
    End With
    GoTo PrintDoc
End Select

PrintDoc:
Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
        wdPrintDocumentWithMarkup, Copies:=1, Pages:="", PageType:= _
        wdPrintAllPages, Collate:=True, Background:=True, PrintToFile:=False, _
        PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
        PrintZoomPaperHeight:=0
End Sub

Last edited by macropod; 10-04-2018 at 01:39 PM. Reason: Added code tags
Reply With Quote
  #2  
Old 10-04-2018, 01:46 PM
JennyWaley JennyWaley is offline Print settings used based on active printer Windows 10 Print settings used based on active printer Office 2016
Novice
Print settings used based on active printer
 
Join Date: Oct 2018
Posts: 2
JennyWaley is on a distinguished road
Default

Nevermind. I figured it out. It is a case sensitivity issue where on Windows 7, the macro didn't care if the printer name was upper or lower case. NOW...that changed. All fixed
Reply With Quote
  #3  
Old 10-04-2018, 06:43 PM
Guessed's Avatar
Guessed Guessed is offline Print settings used based on active printer Windows 10 Print settings used based on active printer Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,984
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Using Select Case allows you to be much more succinct with your code by grouping values. There is no value in the goto statement since the code would go there next anyway
Code:
Sub PrintLetterhead()
Dim defprinter As String

defprinter = UCase(Mid(ActivePrinter, 1, 20))
Select Case defprinter
    Case "\\GS-DC2\MFP1", "\\GS-DC2\MFP2", "\\GS-DC2\MFP3", "\\GS-DC2\MFP4", "BOOKKEEPING XEROX WORKCENTRE PRO 5335"
      With ActiveDocument.PageSetup
        .FirstPageTray = 260
        .OtherPagesTray = 259
      End With
    Case "\\GS-DC2\MFP5", "\\GS-DC2\MFP6"
      With ActiveDocument.PageSetup
        .FirstPageTray = wdPrinterMiddleBin
        .OtherPagesTray = wdPrinterLowerBin
      End With
    Case Else
      With ActiveDocument.PageSetup
        .FirstPageTray = 258
        .OtherPagesTray = 259
      End With
End Select
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Print settings used based on active printer Quick Print Set to Specific Printer? SMNRyan Word 2 06-20-2013 01:04 PM
MS Word 2003, printer queue in 'printer properties' shows 1 job; no job in printer benhuxham Word 0 07-25-2011 06:58 PM
Print settings used based on active printer printer can't print out the lines pclum Word 4 07-02-2011 02:36 AM
Print settings used based on active printer Print orientiation disregarded by the printer Nonplussed Word 1 02-03-2011 03:20 PM
Print settings used based on active printer Word retains printer settings Nathalie Palmer Word 3 01-06-2011 01:50 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:33 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft