Exporting a report to PDF, How do you add code to open the pdf


I have a report that I export to PDF through code. I have this code attached to a button on my main form. When the code runs it saves the PDF to my selected folder ok but I can not work out what code to added to get the pdf file to open automatically after the export.

This is my code:

DoCmd.OutputTo acOutputReport, "rptFINALCentreTotals", acFormatPDF, , , , , acExportQualityScreen

Is anyone able to help me to work out what code needs to be added to have the pdf file open after export?

Many Thanks

Sponsored Links:

Now that the modules are in place to enable a report to be printed to an Acrobat file (thanks to a certain Mr. Getz), the next hurdle is to figure out how to get the hyperlink fields to be recognized in the transfer. In short . . .

Is it possible to automatically generate hyperlinks when exporting a report to a *.pdf file?

Or, is there any way to generate a report that can show both OLE objects and hyperlinks?

This may not have an answer in modules, and for that, I apologize.

How do you add a field to an existing query using vba? Using MS Access module

I need to add/append a table field to an existing select query and save the query using vba code.

1. I will specify the name of the field to be added
2. I need to specify the table it is added from
3. I need to specify in the totals row that it is "SUM"
4. I also need to specify the caption for the newly added field

Then I will save the query

This query is tricky because I am using the "SUM" totals for most of my existing query fields except for 2.

I have been trying to figure this out for a day and a half and I am getting nowhere, ANY help would be appreciated.

I cannot even figure out the code to alter the query.

How do you add a surfix like "-1.rm" to a data field?

I'm currently setting up a database which is updated from a web page, one of the data fields is called "CatNo" and I'd like this field to be copied to four other fields within the same database, within each of the four fields I like a different sufix "-1.rm", "-2.rm", "-3.rm" and "-4.rm.

Is this possible and if so, how?

Thanks all!

How would I go about exporting a report to a word template bookmark using VBA


I want to export a report to excel. Can I do that with a macro? I'm looking through the choices and the Transfer Spreadsheet option is asking me for a table, not a report.



Hi All

I don't think that this should really be at all that complicated, since Office already has mail-merge functionality using Word & Outlook.

All I'm trying to achieve is to email my current database of people with their details as contained in the DB and allow them to ammend incorrect details and add details to open fields (where applicable). This can be done quite simply using the Option in Access: External Data | Collect Data | Create Email. Using the wizard that comes up you can configure it with the relevant fields and it gives an option for a subject and Introduction.

Here's the teaser: How do you add the person's "First Name" as a mail merge field from the Database into the introduction of the email? It seems somewhat obvious to be able to do this, and yet I haven't found a way to! Of course if there's a way in which I can manually create the emails (via mail-merge in Word?), with the relevant fields which update the DB automatically (as does the collect data option in Access) then I'd be happy to try it that way.

Any ideas out there?

Hi Folks

I've added a button to my switchboard that I want to use to print a report to PDF automatically. The following code takes me as far as the 'Save PDF File As' dialogue box:
Code: Dim stDocName As String stDocName = "MyReport" Set Application.Printer = Application.Printers("Adobe PDF") DoCmd.OpenReport stDocName, acNormal Set Application.Printer = Nothing Can anyone tell me how to accomplish the following?
Automatically insert the file name (it will always be 'Work Overview').Simulate hitting 'Save'.Simulate answering 'Yes' when asked if I want to overwrite the existing PDF file of that name.Prevent the new PDF file from opening automatically.Any suggestions would be appreciated.



PS I'm aware of 'Stephen Lebans's ReportToPDF' offering, but I can't download zip files.

I am exporting a report to a text file. When I preview the report, it shows the entire report. When I then right click and select export to a text file, only part of the report is exported.

I have included:
1. A pdf of the entire report when I preview it
2. A text file of what is exported.
3. What is in the database fields
4. The layout of the database.

I have tried multiple things:
1. Shortening the information that is in each database field.
2. Changing the page setup to a legal size page, even up to an 11x17 page. All of the information always shows up when I preview the report, but does not export properly.

I would greatly appreciate any help. I have to have my project go live and I need to be able to export the file.

Thanks in advance! Attached Files report.txt (6.3 KB, 2 views) report design layout.txt (104 Bytes, 2 views) report - what is in database fields.txt (6.6 KB, 1 views) report.pdf (49.9 KB, 2 views) Reply With Quote 02-22-2013, 07:39 PM #2 June7 Super Moderator Windows XP Access 2010 32bit Join Date May 2011 Location The Great Land Posts 15,107 This is export to html?

Are some of the fields memo datatype?

What would the VBA command line look like to export a report to Excel using a command button ?

I have to generate a catalogue from an access application.

This catalogue must be in a single .pdf file, and in single pdf file, but there are different reports to print.
I can use Adobe Acrobat to create pdf file, using VBA.

The problem is:
- How autosave the file xxx.pdf without dialog window ?
- How add a report to an existing file .pdf?

Do you know some link, or information that can help me?



I got a tough one here. I am creating a Labels report in MS Access. The users would like a button to click to export this report to MS Word and then in MS Word they can do what they need to do to work with the report.

If anyone has any ideas about how to best start or work on this let me know.

Thank you,


Hi folks,
Does anyone know how to convert access report to PDF via VBA by clicking a button?

I am building a report on the fly which will be based on:
- selecting a project through a combo box
- and building a query by joining several tables related to that project
and then I should export this with a button below the combo box labeled as ''Export to PDF".

Currently, as you notice in the form (attached) I have two buttons, one “Preview” and another one “Export”. The preview button will display the access report with some formatting features. Once the user views the report in access, then they can export to excel by clicking the “Export” button. It exports to excel exactly as access reports with all formatting and open the excel application and show the report in excel and now the user can save this as an excel file. It works perfectly fine. I have a request from the customer to create a button for exporting to PDF so that no can change the data.
So, I would like to do the same with another button like excel to export to PDF. Any tips/helps are greatly appreciated. I am using Access 2003.

Hi all,

Im hoping someone can help me out here, Im quite a novice so please bear with me, Ive created a database to log phone calls taken- who (from drop down list) took the call, and the reason for the call (a few other similar details too), I have created a report that I print out every week, I've managed to get it to doo all the dates as I want, but I now have two problems,

1. I cant get the report longer than about 4 pages- it just wont let me extend it, can anyone advise on this- I've had to make it in 2 parts!!

2. Im trying to export the report- it has a few graphs and things on it, I have previously used docmd.output acreport "NAME OF REPORT",,AcformatRTF (sorry cant remember exact line- im not at work), but the important bit is the ACformat.RTF part, if I do this, i dont get the charts (since its a RTF file), is there a way to print a report to a word (doc) file keeping it intact, also, if I cant increase the lenght of the report, is there a way to merge 2 reports onto the same word document?

Thanks for any advice you can offer

In access 2007 how do you transfer say a report to your desk top (I have tried ruuning the macro 'Output to') but I keep getting an unreadable file.
Also how do you maniplulate the font or colour when exporting the file?



I have a database that produces timesheets for employees based on employee information and grouped by department information in tblDetail. I have a macro that exports the report Timesheets into excel. I need one Timesheet report to for each department to be exported to excel. So I think I need to create a module that contains a loop that looks in the tblDistribution for the Department id the exports each report to excel. I am stuck on how to do this. Please help. I need to make this as easy as possible for the payroll person. At the moment they are printing reports and manually keying in all the information one person at a time. I have the two table names below...

tblDetail.EmpliD, Pay Group, fileNbr, Period End Date, Pay Date, Day, Hours, Code, Shift, Amt, Temp Dept, Dept ID, Department Name, Department Mgr, Deptsupv, Std Hours, Name, Mgr Name, Mgr Email

tbl_Distribution.Dept ID, Dept Timesheet Manager, Department TimesheetManager Email, Department Name


Can you export a report into excel using a button and VBA? If so what is the code to do that?

I would like to export a report to PDF format. However, I don't want to use the report name as the default file name. Is it possible to do that?

Report Name: Report1
Desired .pdf name: PDFFile

Here is the code I am using, but when you do save it the file name defaults to Report1

Code: DoCmd.OutputTo acOutputReport, "Report1", "PDF Format (*.pdf)", "", False, "", 0, acExportQualityPrint Thank you!

I have become the statistician for my son's hockey team. I currently can create a scoring report in Access and can print the report, use a scanner to create a jpeg file and post the jpeg file to the team web site.

I was wondering if anyone has used Access to export a report directly as a JPEG file? That way I can skip the part about scanning. The forum has had some interesting posts about exporting as a pdf file but nothing about jpegs.

Thanks in advance

I read a number of posts on this forum and although other users have experienced the same issue, there were no clear answer yet. Perhaps with some new knowledge someone can assist.

I'm trying to export a report to Excel.
I'm using Access 2010, but the client only have Excel 2003.
I run:
DoCmd.OutputTo acOutputReport, "MyReportName", acFormatXLS, , True

When I run it on my PC is works (design time).
When I run it on the client PC (with Access 2010 - design time), it works.
When I run it on the client PC (with the Access runtime), it does not work.

I get the error: The format in which you are attempting to output the current object is not available.

From the other posts in this forum, the closest suitable answer is that it is not possible and you can only export queries. I do believe there's a solution to export a report.