By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,474 Members | 1,001 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,474 IT Pros & Developers. It's quick & easy.

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

P: 1
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.

Expand|Select|Wrap|Line Numbers
  1. *******************
  2.  
  3. Private Sub View_Report_Click()
  4.  
  5. Dim blRet As Boolean
  6. Dim fileName, Report, msg1 As String
  7. Report = "rptInvoice"
  8. fileName = "C:\Invoices\PDF Files" & Replace(Date, "/", "") & ".pdf"
  9.     DoCmd.OpenReport Report, acViewPreview
  10.     blRet = ConvertReportToPDF(Report, vbNullString, fileName, False, True, 1, "", "", 0, 0)
  11.     DoCmd.Close acReport, Report
  12.     sbSendreturnform fileName
  13.  
  14. End Sub
  15.  
  16. *********************
Getting a "ByRef argument type mismatch" error on this line (highlighting Report):
blRet = ConvertReportToPDF(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?
Feb 3 '11 #1
Share this Question
Share on Google+
1 Reply


Expert Mod 2.5K+
P: 2,545
As a first step please replace your second Dim statement with

Expand|Select|Wrap|Line Numbers
  1. 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
Feb 3 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.