Solved

Access 2007 Report

Posted on 2010-09-09
6
319 Views
Last Modified: 2012-06-21
I have a Access 2007 report that I want to convert to PDF and then save. I want the save as dialog box to come up so the user can choose a folder to save it to. I am using a macro (specs below) to create the PDF and tried using the msofiledialogsaveas to open the dialog box. the trouble is, I can't get them to work together.

Object Type:  Report
Object Name:  rptPendingDateChanges
Output Format: PDF Format(*.pdf)
output file:  had a path and file name here before
auto start: NO
Template File:  
Encoding:  
Output Quality: Print
0
Comment
Question by:LeLeBrown
  • 3
  • 2
6 Comments
 
LVL 2

Expert Comment

by:Orgrim
Comment Utility
Hello,

If you are using the "Microsoft Office Save as PDF Plug-in", you can setup the "Adobe PDF" printer to ask for file prompt before printing the file  (right click your adobe printer in your printer list and show properties, go in the general tab).
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
the macro can not take variables. To make this work using the msofiledialogsaveas, you have to create a function in vba.

post the codes you are using with the msofiledialogsaveas.

you can do this without using a macro if you want.
0
 

Author Comment

by:LeLeBrown
Comment Utility
Capricorn1,

with msofiledialogsaveas i just have that statement right now. it has been a while since I have created a file in Access. All I have right now is below.

DoCmd.SetWarnings False
 strStatus = SysCmd(acSysCmdSetStatus, "Creating report, please wait ...")
 DoCmd.RunMacro "ReportToPDF"
     strStatus = SysCmd(acSysCmdClearStatus)


Set dlgOpen = Application.FileDialog(msoFileDialogSaveAs)
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
Comment Utility
create a command button in a form and name it cmdSavePDF

in the click event of the button place the code like this

you have to add to your references Microsoft office xx.x object library


Private Sub cmdSavePDF_Click()

On Error GoTo SavePDFerr

Dim dlgOpen As Office.FileDialog, pdfFile As String

Set dlgOpen = Application.FileDialog(msoFileDialogSaveAs)

With dlgOpen

    .AllowMultiSelect = False

    .Title = "Save PDF file"

    .Show

    pdfFile = .SelectedItems(1)

End With

If Len(pdfFile & "") > 0 Then

DoCmd.OutputTo acOutputReport, "rptPendingDateChange", acFormatPDF, pdfFile, , , , acExportQualityPrint



End If

Exit_SavePDF:

    Exit Sub



SavePDFerr:

    If Err.Number = 5 Then

        Err.Clear

        Else

        MsgBox Err.Description

    End If

        Resume Exit_SavePDF



End Sub

Open in new window

0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
or you can use this sample db
dbSavePDFAs.mdb
0
 

Author Comment

by:LeLeBrown
Comment Utility
Capricorn1,

Thanks!!  This worked great!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now