Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

https://stackoverflow.com/questions/23957735/excel-vba-print-margin-seems-to-be-ignored

https://docs.microsoft.com/en-us/office/vba/api/excel.sheets.printout

'''''PRINT'''''
Public Sub SetPrinterToDuplex() 'Not Working
    Dim sPrinterName
    sPrinterName = "EPSON60798C (WF-2630 Series)"
    SetPrinterDuplex sPrinterName, 2
End Sub

Public Sub PrintSetup()

Const xlLandscape = 2

With Application
 With .ActiveSheet
 With .Pagesetup
  .Orientation = xlPortrait
  .Zoom = False
  .FitToPagesWide = 1
  .FitToPagesTall = False
  .LeftMargin =  0.75
  .RightMargin =  0.25
  .TopMargin =  0.75
  .BottomMargin = 0.75
  .HeaderMargin = 0.3
  .FooterMargin = 0.3
  .PrintTitleRows = "$1:$1"
  .PrintTitleColumns = ""
 End With
 '.PrintPreview 'Use PrintPreview for Debugging
 '.PrintOut ActivePrinter:="\\%SERVER%\%PRINTER%" 'Hard Code Printer
 '.PrintOut ActivePrinter:="EPSON60798C (WF-2630 Series)" 'Print via Specific Printer 
 '.PrintOut  'Generic Print via Default
 End With
 .Dialogs(xlDialogPrint).Show
End With
With Application
 .DisplayAlerts = False 'No Save Dialogue
 .Quit
End With
End Sub
'''''ENDPRINT'''''
  • No labels