title: VBA in Excel 2016 - set printer settings in code
body: <p>I've scoured the internet but can't find an exact solution for this...I need to be able to set the color and duplex settings for printing from within my VBA code.</p>
  
  <p>My intent is to use a VBA userform button to format and then print a table from my workbook. My abbreviated code is:</p>
  
  <pre><code>Application.PrintCommunication = False
  With ws.PageSetup
      .PrintArea = first &amp; ":" &amp; last
      .PrintTitleRows = "$1:$1"
      .LeftHeader = "&amp;9&amp;D &amp;T"
      .CenterHeader = "&amp;A"
      .RightHeader = "&amp;9Page &amp;P of &amp;N"
      .Orientation = xlLandscape
      .PaperSize = xlPaper11x17
      .LeftMargin = Application.InchesToPoints(0.25)
      .RightMargin = Application.InchesToPoints(0.25)
      .TopMargin = Application.InchesToPoints(0.5)
      .BottomMargin = Application.InchesToPoints(0.25)
      .HeaderMargin = Application.InchesToPoints(0.3)
      .FooterMargin = Application.InchesToPoints(0.3)
  End With
  Application.PrintCommunication = True
  
  ws.PrintOut Preview:=True, ActivePrinter:="BODHPM750"
  </code></pre>
  
  <p>This formats the page and opens the preview window fine, but it defaults to black-and-white one-sided printing (per the office's printer settings) unless I've manually changed it since opening the workbook. These settings are associated with the printer, not the workbook, so I can't change them through ws.PageSetup or within the preview window.</p>
  
  <p><strong>EDIT:</strong> I also realized that the ActivePrinter definition isn't working. The print preview is opening for the default printer set on my computer, which is a different one from the one I'm trying to call in my ws.PrintOut command.</p>
  
  <p>Is there a way for me to set this to print in color and duplex within this button press? I found information on using a Printer object within Access and other Office programs, but there doesn't seem to be one for Excel.</p>
  
  <p>For reference - I'm using VBA in Excel 2016 and the printer I'm trying to use is an HP Color LaserJet M750 PCL 6 on an office server, if that's relevant.</p>
  
  <p><strong>UPDATE:</strong> Color issue resolved.</p>