Hi all,
Despite googling and searching for solutions for many days, I keep having a problem. I know it has been discussed before, but I cannot find a solution for my case. It is really driving me nuts.
One of the users of my application, reports an error when saving a report to pdf by VBA code. She’s using Access 2013, on Windows 8.1.
The error is “error 2501 outputto action was cancelled with access vb macro”
The VBA code is
StrReport = “RepInvoice”
StrDocumentName = “C:\Users\Mary\Documents\Access\Invoice.pdf”
DoCmd.OpenReport StrReport, acViewPreview
DoCmd.OutputTo acOutputReport, StrReport, "PDFFormat(*.pdf)", StrDocumentName, False
DoCmd.Close acReport, StrReport, acSaveNo
This errror occurs at the OutputTo line. This code is part of an user form with a button “save as PDF”.
When this code is run, the report is visible as an example (as meant to be) on the screen. The code stops at the OutputTo line.
When I use
DoCmd.OutputTo acOutputReport, StrReport, acFormatPDF, StrDocumentName,, False
the problem still exists.
I tried to save the report manually by Preview > Export > PDF. The preview is OK, saving as PDF results in the same error 2501.
This may lead to the conclusion that this problem is not caused by the VBA code.
I verified whether user write rights are OK, and whether a default printer is available. Both are OK.
The report consists of 1 page.
When this very same application is used with Access 2010, everything functions as expected.
Who has any idea about the cause and a possible solution?
Thanks in advance,
Paul
Despite googling and searching for solutions for many days, I keep having a problem. I know it has been discussed before, but I cannot find a solution for my case. It is really driving me nuts.
One of the users of my application, reports an error when saving a report to pdf by VBA code. She’s using Access 2013, on Windows 8.1.
The error is “error 2501 outputto action was cancelled with access vb macro”
The VBA code is
StrReport = “RepInvoice”
StrDocumentName = “C:\Users\Mary\Documents\Access\Invoice.pdf”
DoCmd.OpenReport StrReport, acViewPreview
DoCmd.OutputTo acOutputReport, StrReport, "PDFFormat(*.pdf)", StrDocumentName, False
DoCmd.Close acReport, StrReport, acSaveNo
This errror occurs at the OutputTo line. This code is part of an user form with a button “save as PDF”.
When this code is run, the report is visible as an example (as meant to be) on the screen. The code stops at the OutputTo line.
When I use
DoCmd.OutputTo acOutputReport, StrReport, acFormatPDF, StrDocumentName,, False
the problem still exists.
I tried to save the report manually by Preview > Export > PDF. The preview is OK, saving as PDF results in the same error 2501.
This may lead to the conclusion that this problem is not caused by the VBA code.
I verified whether user write rights are OK, and whether a default printer is available. Both are OK.
The report consists of 1 page.
When this very same application is used with Access 2010, everything functions as expected.
Who has any idea about the cause and a possible solution?
Thanks in advance,
Paul