Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving an Access 97 Report as a PDF File

Status
Not open for further replies.

Arob

Technical User
Jul 25, 2001
55
US
I am trying to save a report as a PDF File instead of a
RTF File and am having some difficulties with the code.
Below is my code for saving and Emailing the Report as an
RTF. I have not been able to change the RTF settings to PDF and have any luck. Just wandering if anyone has a solution. Thanks

Public Sub Savegraph_Click()

On Error GoTo ExportGraph_Err
Dim strErrMsg As String 'For Error Handling
Dim oleGrf As Object
Dim strFileName As String
Dim strFilter As String
Dim lngFlags As Long
Dim olApp As New Outlook.Application
Dim olNameSpace As Outlook.NameSpace
Dim olMail As Outlook.MailItem

Set olNameSpace = olApp.GetNamespace("MAPI")
Set olMail = olApp.CreateItem(olMailItem)
DoCmd.OpenReport "RPTSNFREPORT", acViewPreview
Set oleGrf = Reports("RPTSNFREPORT")

strFileName = ahtCommonFileOpenSave(Flags:=lngFlags,
InitialDir:="C:\", _
Filter:="Rich Text Format Files (*.rtf)",
FilterIndex:=1, DefaultExt:="rtf", FileName:="MyReport", _
DialogTitle:="Save the Report", OpenFile:=False)

DoCmd.OutputTo acOutputReport, "RPTSNFREPORT", _
acFormatRTF, strFileName, False
MsgBox vbCrLf & "The Report " & strFileName & " has been
exported", _
vbInformation + vbOKOnly, "Report exported :"

With olMail
.To = "aroberts@guidemail.com"
.Subject = "Report Info: " & Format(Now(), "dd mmm
yyyy hh:mm")
.Attachments.Add strFileName
.ReadReceiptRequested = False
.Display
End With
Kill strFileName

MsgBox vbCrLf & "Chart has been E-Mailed", _
vbInformation + vbOKOnly, "Chart Exported :"


ExportGraph_Exit:
Set olApp = Nothing
Set olMail = Nothing
Set oleGrf = Nothing
Exit Sub

ExportGraph_Err:
Select Case Err
Case 1004 ' Export Cancelled
Resume ExportGraph_Exit
Case Else
strErrMsg = strErrMsg & "Error #: " &
Format$(Err.Number) & vbCrLf & vbCrLf
strErrMsg = strErrMsg & "Error Description: "
& Err.Description & vbCrLf
MsgBox strErrMsg, vbInformation, "ExportGraph"
Resume ExportGraph_Exit
End Select

End Sub
.

 
Not to sound Dumb, but I don't know what the winini file is and I am not sure how to exactly set up according to the instructions they give in the link. I have tried with little success, but errors. Any assistance would be greatly appreciated. Thanks
 
WHy don't you set your report to print to a specific printer? Select the adobe Printer (if you have the reader installed), and that, my friend is that.

Use a macro. Open report in print view - and reference it with a command button.
 
I bought a printer driver for US$19 over the Internet, which makes this as easy aas printing to a regular printer. it came from 602Pro. works like a charm. No code no nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top