Hi Can you please offer me some help in getting my code to execute.
I am getting a "Compile Error: Arguement not Optional" error.
I am using a print button to call my print to PDF function:
BUTTON CODE:
Private Sub Comp_Statement_Click()
DoCmd PrintPDF()
End Sub
FUNCTION:
Function PrintPDF(SrcReport As String)
On Error GoTo PrintToPDF_Err
'Call Function from any report with this: "PrintPDF(Report Name)"
Dim FolderPath As String
Dim FileName As String
Dim ShowPdf As Boolean
'Name report to print
SrcReport = "rpt_Compensation_Basic"
'Saves the file to specific directory
FolderPath = " C:\My Documents\" & [FileFolder] & "\"
'" H:\Private\Compensation\2012 Comp Planning\2011-2012 Final Compensation Statements\" & [FileFolder] & "\"
'Formats the file
FileName = [Full Name] & "-" & [Country] & "-" & [Segment] & "-" & [FileFolder]
ShowPdf = False
DoCmd.OutputTo acOutputReport, SrcReport, "PDFFormat(*.pdf)", FolderPath & FileName & ".pdf", ShowPdf, "", 0, acExportQualityPrint
PrintToPDF_Exit:
Exit Function
PrintToPDF_Err:
MsgBox Error$
Resume PrintToPDF_Exit
End Function
Any help would be greatly appreciated.
Thanks
I am getting a "Compile Error: Arguement not Optional" error.
I am using a print button to call my print to PDF function:
BUTTON CODE:
Private Sub Comp_Statement_Click()
DoCmd PrintPDF()
End Sub
FUNCTION:
Function PrintPDF(SrcReport As String)
On Error GoTo PrintToPDF_Err
'Call Function from any report with this: "PrintPDF(Report Name)"
Dim FolderPath As String
Dim FileName As String
Dim ShowPdf As Boolean
'Name report to print
SrcReport = "rpt_Compensation_Basic"
'Saves the file to specific directory
FolderPath = " C:\My Documents\" & [FileFolder] & "\"
'" H:\Private\Compensation\2012 Comp Planning\2011-2012 Final Compensation Statements\" & [FileFolder] & "\"
'Formats the file
FileName = [Full Name] & "-" & [Country] & "-" & [Segment] & "-" & [FileFolder]
ShowPdf = False
DoCmd.OutputTo acOutputReport, SrcReport, "PDFFormat(*.pdf)", FolderPath & FileName & ".pdf", ShowPdf, "", 0, acExportQualityPrint
PrintToPDF_Exit:
Exit Function
PrintToPDF_Err:
MsgBox Error$
Resume PrintToPDF_Exit
End Function
Any help would be greatly appreciated.
Thanks