+ Reply to Thread
Results 1 to 5 of 5

Set Printer name and Setting in Macro

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-10-2016
    Location
    Minneapolis, Minnesota
    MS-Off Ver
    Office 365
    Posts
    124

    Set Printer name and Setting in Macro

    Hi,

    I have a Macro that executes commands and prints right after.
    Before I execute the macro, I need to go and change printer and printer settings.
    Is there a way to include printer name and settings in the beginning of the macro before everything gets executed?

    Printer Name: WestOffice on network1
    Printer Properties:
    Job Type
    Normal Print
    Color / Black and White
    Color


    Thanks,
    Yuriy
    Last edited by YuriyBaron; 10-16-2017 at 03:12 PM.

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Set Printer name and Setting in Macro

    .

    Here is a resource from the Net :

    Sub SelectPrinter()
    	Dim sNewPrinter As String
    
    	sNewPrinter = ActivePrinter
    	ActivePrinter = "Enter the Windows name of the printer here"
    
    	Application.PrintOut FileName:=""    '<--- This line would go somewhere further down in the sub when you are ready to print
    
    	ActivePrinter = sNewPrinter
    End Sub

    This resource has a more descriptive macro and specifies B&W color printing :

    https://windowssecrets.com/forums/sh...g-in-vba-macro


    From MS: https://msdn.microsoft.com/en-us/vba...property-excel

    Worksheets("Sheet1").PageSetup.BlackAndWhite = True


    And ... you can always use the MACRO RECORDER while you go through the Print Setup routine. The resulting macro should be at least very close to what you are seeking.

    Trust something here works for you.
    Last edited by Logit; 10-16-2017 at 03:38 PM.

  3. #3
    Forum Contributor
    Join Date
    08-10-2016
    Location
    Minneapolis, Minnesota
    MS-Off Ver
    Office 365
    Posts
    124

    Re: Set Printer name and Setting in Macro

    Great,

    Based on what you wrote, I made this:

    
    
    Option Explicit
    Sub SelectPrinter()
        Dim sNewPrinter As String
    
        sNewPrinter = ActivePrinter
        ActivePrinter = "XXXXXWestOffice on XXX-XX-001.office.XXXXXsmfg.com"
        Sub MacroPint3()
        On Error Resume Next
        
        Call Prt_001
        Call Prt_002
        Call Prt_003
        Call Prt_004
        Call Prt_005
        Call Prt_006
        Call Prt_007
        Call Prt_008
        Call Prt_009
    End Sub
    
    Sub Prt_001()
      With Worksheets("Pnch, Asy, Oth, Mach SchedRsc").PivotTables("PivotTable2")
            .PivotFields("SchedGroup").ClearAllFilters
            .PivotFields("SchedGroup").CurrentPage = "Assembly"
            .PivotFields("Rsc").ClearAllFilters
            .PivotFields("Rsc").CurrentPage = "(All)"
             Application.PrintOut Filename:=""                             '<--- NEW
            .Parent.PrintOut Options.PrintDraft = False                    '<--- NEW
      End With
    End Sub
    
    Sub Prt_002()
      With Worksheets("Brk SchedPrimeRq").PivotTables("PivotTable1").PivotFields("SchedGroup")
        .ClearAllFilters
        .CurrentPage = "Brake"
        Application.PrintOut Filename:=""                              '<--- NEW
        .Parent.Parent.PrintOut Options.PrintDraft = False             '<--- NEW
      End With
    End Sub
    
    Sub Prt_003()
      Dim vs            As Variant
      With Worksheets("Asy,Lsr,HW,WD,SW,PC SchedRqList").PivotTables("PivotTable2").PivotFields("SchedGroup")
        For Each vs In Array("Powder", "SpotWeld", "Weld", "Hardware", "LASER")
          .ClearAllFilters
          .CurrentPage = vs
        Application.PrintOut Filename:=""                              '<--- NEW
          .Parent.Parent.PrintOut From:=1, To:=3, Copies:=1
          Options.PrintDraft = False                                    '<--- NEW
        Next vs
      End With
    End Sub
    How would I specify in printer Setting Job Type: Normal Print

    Thanks,
    Yuriy
    Last edited by YuriyBaron; 10-16-2017 at 04:09 PM.

  4. #4
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Set Printer name and Setting in Macro

    .
    I am at a loss with this question. I've searched the NET for one hour and cannot locate anything pertaining to Print: Normal. Tried every search term I can think of regarding
    the Print Job Type.

    This is dangerous (you know what they say about assuming), but I presume if you don't specify a print job type, it should be normal by default ?

  5. #5
    Forum Contributor
    Join Date
    08-10-2016
    Location
    Minneapolis, Minnesota
    MS-Off Ver
    Office 365
    Posts
    124

    Re: Set Printer name and Setting in Macro

    Unfortunately the reason why I need to specify the Job Type is that the default setting is set to "Sample Print" and not "Normal Print".

    Do my changes in the code make any sense?

    Thanks,
    Yuriy

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Setting a default Printer for a macro then resetting it back to its original value
    By ashvinsolanki in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-03-2014, 12:08 PM
  2. Setting the default printer
    By martinpgibson in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-19-2013, 05:43 PM
  3. Printing Macro Problem - Setting Default printer
    By jordan2322 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-18-2012, 03:37 AM
  4. macro to print 2 copies to default printer, then 1 copy to Adobe PDF printer
    By jwright650 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-26-2011, 01:07 PM
  5. setting PDF Creator as a default printer thro VBA macro
    By mvel_sky in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-01-2010, 01:43 AM
  6. Setting EDoc Printer Pro in macro
    By Frank in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-05-2006, 10:55 AM
  7. Setting printer in VB
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-21-2005, 06:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1