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
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..
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. :banghead:
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"