The OutputTo action was canceled 2501 (1 Viewer)

Hello1

Registered User.
Local time
Tomorrow, 01:24
Joined
May 17, 2015
Messages
271
I cant get to export my report as PDF with the OutputTo command.
First I was getting another error that it was not supported if I remember right and found out an add on which has to be installed from microsofts wibsite.
https://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=7

After that Im getting the error in the title.
This is my code
Code:
Dim FileName As String
Dim FilePath As String

FileName = Me.cboBox1.Value
FilePath = " D:\PDF\" & FileName & ".pdf"

DoCmd.OpenReport "rptReport1", acViewPreview, , , acHidden
DoCmd.OutputTo acOutputReport, "rptReport1", acFormatPDF, FilePath

'From immediate window
?FilePath
 D:\PDF\MGI.pdf

First I tried without DoCmd.OpenReport but same thing, now with it also.
If I remove the FilePath I get the popup window and can save the PDF normally. So I did next..

Code:
DoCmd.OutputTo acOutputReport, "rptReport1", acFormatPDF, "D:\PDF\MGI.pdf"
And this works just fine. I tried with manually setting FileName = "MGI" and FileName = Me.cboBox1 but same thing it doesnt want to work from a variable. :confused: :banghead:
 

June7

AWF VIP
Local time
Today, 14:24
Joined
Mar 9, 2014
Messages
5,470
Don't know if will cause issue but code shows a space in front of D in the FilePath expression.
 

Hello1

Registered User.
Local time
Tomorrow, 01:24
Joined
May 17, 2015
Messages
271
:eek: :eek:
That was it, darn how I miss those simplest things :banghead:
A sharp eye u have :)
Thanks!
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 17:24
Joined
Feb 28, 2001
Messages
27,183
Good catch, June7. Spaces in filenames count because, unfortunately, they are legal. E.g. "C:/Documents and Settings/" as a path used to be absolutely valid.
 

Users who are viewing this thread

Top Bottom