VBA Help

krishnaoptif

Board Regular
Joined
Sep 17, 2010
Messages
140
Hi Experts,

I am using below code in my access report to download in to pdf report in a folder... this code is working fine in Access 2007 at my home system... but in my office i am using Access 2003 so in 2003 version the below code is not working ... this is giving me below Error msg ---

"run-time error '2282' the format in which you are attempting to output the current object is not available"

I am waiting for your reply..

my code which is not working with Access 2003 but working fine with Access 2007

Code:
Public Function PrintPDF2(SrcReport As String, CustName As String)

Dim MyFilter As String
Dim MyPath As String
Dim MyFilename As String

'create new folder
If Len(Dir("E:\Krishna\Live\Joe\PDFReport\" & Format(Date, "DD-MMM-YYYY") & "", vbDirectory)) = 0 Then
    MkDir "E:\Krishna\Live\Joe\PDFReport\" & Format(Date, "DD-MMM-YYYY") & ""
End If


'I place the file on a different folder depending on the date stated in a field called "Date"
MyPath = "E:\Krishna\Live\Joe\PDFReport\" & Format(Date, "DD-MMM-YYYY") & "\" '& Format(Date, "yyyy")

'State the filename. Here I use YYYY-DD-MM-Event.pdf

MyFilename = Format(Date, "DD-MMM-YYYY") & "_" & CustName & ".pdf"

'Let's print and save. Once you see it works, you can change True to False so that the file created is not opened after completion.
DoCmd.OpenReport SrcReport, acViewPreview
DoCmd.OutputTo acOutputReport, "", acFormatPDF, MyPath & MyFilename, False

'Let's close our previewed report
DoCmd.Close acReport, SrcReport


End Function
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Exporting to PDF is not natively available with Access 2003. You must install a PDF printer in that case (such as CutePDF, bullzip, PDF995, etc. etc.) - then print the report using the installed PDF printer. Win2PDF seems to work very well with VBA and is my preference.
ξ
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,849
Members
449,051
Latest member
excelquestion515

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top