How to fix "ByRef argument type mismatch" error when saving as pdf?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Shelley Burke
    New Member
    • Feb 2011
    • 1

    How to fix "ByRef argument type mismatch" error when saving as pdf?

    Many thanks for the coding provided in an earlier thread to be able to snapshot document, save as pdf and email it.

    Unfort I have done everything as instructed and am still having problems.

    Code:
    *******************
    
    Private Sub View_Report_Click()
    
    Dim blRet As Boolean
    Dim fileName, Report, msg1 As String
    Report = "rptInvoice"
    fileName = "C:\Invoices\PDF Files" & Replace(Date, "/", "") & ".pdf"
        DoCmd.OpenReport Report, acViewPreview
        blRet = ConvertReportToPDF(Report, vbNullString, fileName, False, True, 1, "", "", 0, 0)
        DoCmd.Close acReport, Report
        sbSendreturnform fileName
    
    End Sub
    
    *********************
    Getting a "ByRef argument type mismatch" error on this line (highlighting Report):
    blRet = ConvertReportTo PDF(Report, vbNullString, fileName, False, True, 1, "", "", 0, 0)

    The name of my report is rptInvoice and I created the folders to put the PDF into.

    I changed the Report to View Report got a syntax error. Changed the report name to ReturnsForm as you had it, get byRef error again :(

    Where am I going wrong?
    Last edited by Stewart Ross; Feb 3 '11, 12:53 PM. Reason: Modified title from Mandanarchi??? and added code tags
  • Stewart Ross
    Recognized Expert Moderator Specialist
    • Feb 2008
    • 2545

    #2
    As a first step please replace your second Dim statement with

    Code:
    Dim fileName as String, Report as String, msg1 As String
    In VBA each variable declaration is separate, even if they are on the same line; Using var1, var2, var3 = sometype does NOT define var1 and var2 to be the same as var3; when no type is specified Variant is the default, which is likely to have caused the error in the call that you highlighted.

    -Stewart
    Last edited by Stewart Ross; Feb 3 '11, 12:56 PM.

    Comment

    Working...