rogerdjr
asked on
Access 2013 Set Printer Page Format from vba
I use this code to print a weekly meeting agenda and I have been manually adjusting the report in acrobat to print an 11x17 working copy for note taking - I would like to automate this process without creating a 2nd report
WkgWklyMtgRptFilter = "[ContractId] = " & """" & Forms![0_masterdatafrm]![D efaultCont rId] & """" & " and [MeetingNumber] = " & Me![MeetingNumber]
RptNm = "80_ConstrMtgAgendaWkgRpt"
RptNmlng = Forms![0_masterdatafrm]![D efaultCont rId] & " MRWMD Truck Haul Project Wkly Cnstr Mtg Agenda " & Format(Me![MeetingNumber], "000") & " " & Format(Me![MeetingDate], "mm-dd-yyyy") & ".pdf"
DoCmd.OutputTo objecttype:=acOutputReport , objectname:=RptNm, OutputFormat:=acFormatPDF, OutputFile:=PrntPath & RptNmlng
J--14-Jobs-14040-MRWMD---Owners-Rep---CM
J--14-Jobs-14040-MRWMD---Owners-Rep---CM
WkgWklyMtgRptFilter = "[ContractId] = " & """" & Forms![0_masterdatafrm]![D
RptNm = "80_ConstrMtgAgendaWkgRpt"
RptNmlng = Forms![0_masterdatafrm]![D
DoCmd.OutputTo objecttype:=acOutputReport
J--14-Jobs-14040-MRWMD---Owners-Rep---CM
J--14-Jobs-14040-MRWMD---Owners-Rep---CM
ASKER
Tried this code based on the link - it changes the printer named Adobe PDF to landscape 11 x 17 but doesn't print an 11 x 17 report?
Private Sub PrintTabloidPdfsBtn_Click( )
Dim strDistillerPrinter As String
Dim strPrinterName As String, strDefaultPrinter As String
Dim prt As Access.Printer
Dim Orientation As Integer, PaperSize As Integer
Dim WkgWklyMtgRptFilter As String, RptNm As String, RptNmlng As String
'1. Get the name of the system default printer
strDefaultPrinter = application.Printer.Device Name
'2. Get the name of the Distiller printer
'Make Sure the Acrobat Printer is setup to print directly to the printer
For Each prt In application.Printers
strPrinterName = prt.DeviceName
' MsgBox strPrinterName
If prt.DeviceName = "Adobe PDF" Then
MsgBox prt.Orientation & vbNewLine & prt.PaperSize & vbNewLine
Orientation = prt.Orientation '(1 portrait, 2 landscape)
PaperSize = prt.PaperSize '(1 letter, 17 11x17)
prt.Orientation = acPRORLandscape
prt.PaperSize = acPRPS11x17
MsgBox prt.Orientation & vbNewLine & prt.PaperSize & vbNewLine
'Agenda
WkgWklyMtgRptFilter = "[ContractId] = " & """" & Forms![0_masterdatafrm]![D efaultCont rId] & """" & " and [MeetingNumber] = " & Me![MeetingNumber]
RptNm = "80_ConstrMtgAgendaWkgRpt"
RptNmlng = Forms![0_masterdatafrm]![D efaultCont rId] & " MRWMD Truck Haul Project Wkly Cnstr Mtg Agenda " & Format(Me![MeetingNumber], "000") & " " & Format(Me![MeetingDate], "mm-dd-yyyy") & " Tabloid .pdf"
PrntPath = "j:\0\"
DoCmd.OutputTo objecttype:=acOutputReport , objectname:=RptNm, OutputFormat:=acFormatPDF, OutputFile:=PrntPath & RptNmlng
prt.Orientation = Orientation
prt.PaperSize = PaperSize
End If
Next
End Sub
Private Sub PrintTabloidPdfsBtn_Click(
Dim strDistillerPrinter As String
Dim strPrinterName As String, strDefaultPrinter As String
Dim prt As Access.Printer
Dim Orientation As Integer, PaperSize As Integer
Dim WkgWklyMtgRptFilter As String, RptNm As String, RptNmlng As String
'1. Get the name of the system default printer
strDefaultPrinter = application.Printer.Device
'2. Get the name of the Distiller printer
'Make Sure the Acrobat Printer is setup to print directly to the printer
For Each prt In application.Printers
strPrinterName = prt.DeviceName
' MsgBox strPrinterName
If prt.DeviceName = "Adobe PDF" Then
MsgBox prt.Orientation & vbNewLine & prt.PaperSize & vbNewLine
Orientation = prt.Orientation '(1 portrait, 2 landscape)
PaperSize = prt.PaperSize '(1 letter, 17 11x17)
prt.Orientation = acPRORLandscape
prt.PaperSize = acPRPS11x17
MsgBox prt.Orientation & vbNewLine & prt.PaperSize & vbNewLine
'Agenda
WkgWklyMtgRptFilter = "[ContractId] = " & """" & Forms![0_masterdatafrm]![D
RptNm = "80_ConstrMtgAgendaWkgRpt"
RptNmlng = Forms![0_masterdatafrm]![D
PrntPath = "j:\0\"
DoCmd.OutputTo objecttype:=acOutputReport
prt.Orientation = Orientation
prt.PaperSize = PaperSize
End If
Next
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
https://msdn.microsoft.com/en-us/library/office/ff837177.aspx
Click Printer Object Members for required Printer Settings.