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

Hello!

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


Post your answer or comment

comments powered by Disqus
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

Hi,

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.

Thanks

Eddie

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.

Thanks

Remster

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 ?

Hi!
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?

Thanks!!!

Letizia

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,

T.J.

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?

Cheers

Hudson

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

Thanks,
Juliana

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

Hi
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.

Is it possible to save/print a report to a pdf file, by using just code?

I have a report which I would like to have saved/printed, by 'just' clicking a button. Preview of the report is not necessary. The report should be saved in a specific location on the computer, and if possible, I would also like it to be saved with a specific name, such as "Some text + [today's date]".

I have searched around for this a bit, but I haven't been successfull in finding what I would like. I would appreciate if someone can assist in this matter.

/Anders

P.s. Sorry if any dublicates of this post shows up. I had internet connection problems when sending, and had to refresh a few times.

I am trying to place a command button on my form that will convert a report to pdf. I can e-mail through adobe. My issue that I don't want to select a report from a list as setup successfully by Leban. I would like the code to be setup to print the only report needed from my form. In this case it's rptTblUser. How can I modify the code from Leban to print this way? Thanks in advance

blRet = ConvertReportToPDF(Me.lstRptName, vbNullString, _
Me.lstRptName.Value & ".pdf", False, True, 150, "ABC", "DEF", tr, 0)

I believe I need to replace the Me.lstRptName with the actual name of the report. I am not comfortable enough with the syntax to do so

I have pasted a link below to a database I am working on that tracks contract documents. I am having some trouble trying to export a report that is emedded in a form using the BrowseTo method (I believe this feature is new in Access 2010 so it may not work in earlier versions).

Click the "Report Center" tab, then click the "Active Agreements" link on the left side of the page. Select the first option on the pop-up window ("Select a Category"), click OK, then on the next window select "Category 1" in the drop-down menu and click OK.

The "rptActiveContractsByLocation" report will load using the BrowseTo method. On the bottom of the report I added a link to export to PDF. This link uses the DoCmd.OutputTo method and saves a PDF of the report on the user's desktop.

Here is the problem: the PDF report that is generated shows all records; it is not the filtered report that is displayed on the screen. I would like to have a link or button the user can click if they want to export the exact report displayed on screen with the filters applied.

Any help would be greatly appreciated.

Here is the sample database: http://dl.dropbox.com/u/65832352/Exa...Database.accdb

Maybe a silly a question, but I want to know if there's an easy way to export my report to Word in an almost identical copy.

I know how to open word and such, but is there a command that will basically paste my report into a word document?

thanks

Hi,

This is forum has been very helpful to me on my latest database project. I'm now stuck and hoping you all can help me out. This is an urgent request so hopefully someone here has dealt with the same problem.

First off, I hope I'm posting in the right forum.

I'm printing a report to .pdf. I'm using pdf995 and pdf995edit. Upon creating the file, I have code that automatically attaches the file to an e-mail. Everything works great, but I'm finding that after the code executes, the pdf995 printer remains the default. Ideally, I would like the code to execute, print to the pdf995 printer and reset the default printer to the applicable network printer. This is also running across a network. The pdfwriter is on the client, while the database is on a server. Here's the code I'm using now.


	Code:
	Private Sub btnEmail_Click()

' If you don't want the report dialog box being displayed
' asking what name you want to give the pdf report, you will
' need pdfEdit995.  With pdfEdit995t you tell pdf995 what directory
' and what file name to initially give the pdf report.
'
' Quote from PDF; "pdfEdit995 has autoname features. I recommend setting
' the PDF to be named based on the document being printed. Create a
' temporary report with the name of the PDF you want and tell it to
' print to PDF995. The Save As dialog won't appear."

    Dim strDir As String
    Dim strFile As String
    Dim fOK As Boolean

    ' Directory to place the PDF files that are to
    ' be printed
    strDir = "D:Documents and SettingsHeatherMy DocumentsOutsourced ProjectsTyco"
    ' Name of file to create
    strFile = "DFM Summary Statistics Queried " & Format(Date, "Long Date") & ".pdf"
  
    ' Create the report
    DoCmd.OpenReport "rptStats", acViewNormal
    
    ' Copy the created file (name is Output.pdf) to the
    ' directory and file name specified above
    fOK = CopyFile_TSB(strDir & "Output.pdf", strDir & strFile)
     'If the file didn't copy properly, tell the user
    If Not fOK Then
       Beep
       MsgBox "File Copy Failure"
   End If
SendMessage (strDir & strFile)
End Sub

Function CopyFile_TSB(strSource As String, strDestination As String) As Boolean
' Comments  : copies a file
' Parameters: strSource - source file
'             strDestination - destination file
' Returns   : True if successful, False otherwise
'
    Const BufferSize = 9000


    Dim strBuffer As String * BufferSize
    Dim strTempBuffer As String
    Dim intSourceFile As Integer
    Dim intDestinationFile As Integer
    Dim lngCounter As Long

    On Error GoTo PROC_ERR

    intSourceFile = FreeFile
    Open strSource For Binary As #intSourceFile

    intDestinationFile = FreeFile
    Open strDestination For Binary As #intDestinationFile

    For lngCounter = 1 To LOF(intSourceFile)  BufferSize
        Get #intSourceFile, , strBuffer
        Put #intDestinationFile, , strBuffer
    Next lngCounter

   lngCounter = LOF(intSourceFile) Mod BufferSize

    If lngCounter > 0 Then
        Get #intSourceFile, , strBuffer
        strTempBuffer = Left$(strBuffer, lngCounter)
        Put #intDestinationFile, , strTempBuffer
    End If

    Close #intSourceFile
    Close #intDestinationFile
    CopyFile_TSB = True

PROC_EXIT:
    Exit Function

PROC_ERR:
    CopyFile_TSB = False
    Resume PROC_EXIT

End Function

Private Sub btnCancel_Click()
On Error GoTo Err_btnCancel_Click

    Dim stDocName As String

    stDocName = "CustStatsSelect.Cancel"
    DoCmd.RunMacro stDocName

Exit_btnCancel_Click:
    Exit Sub

Err_btnCancel_Click:
    MsgBox Err.Description
    Resume Exit_btnCancel_Click
    
End Sub

Sub SendMessage(Optional AttachmentPath)

           Dim objOutlook As Outlook.Application

               Dim objOutlookMsg As Outlook.MailItem

               Dim objOutlookRecip As Outlook.Recipient

               Dim objOutlookAttach As Outlook.Attachment



               ' Create the Outlook session.

               Set objOutlook = CreateObject("Outlook.Application")



           ' Create the message.

           Set objOutlookMsg = objOutlook.CreateItem(olMailItem)



           With objOutlookMsg

              ' Add the To recipient(s) to the message.

             Set objOutlookRecip = .Recipients.Add("heather@digitalcampground.com")

              objOutlookRecip.Type = olTo


              ' Add the CC recipient(s) to the message.

              Set objOutlookRecip = .Recipients.Add(" ")

              objOutlookRecip.Type = olCC



              ' Set the Subject, Body, and Importance of the message.

              .Subject = "DFM Statistics Summary"

              .Body = ""

              .Importance = olImportanceHigh  'High importance



              ' Add attachments to the message.
                Dim strFile As String
                strFile = "D:Documents and SettingsHeatherMy DocumentsOutsourced ProjectsTycoDFM Summary Statistics Queried "
& Format(Date, "Long Date") & ".pdf"


              If Not IsMissing(AttachmentPath) Then

                 Set objOutlookAttach = .Attachments.Add(strFile)

              End If



              ' Resolve each Recipient's name.

              For Each objOutlookRecip In .Recipients

                 objOutlookRecip.Resolve

                 If Not objOutlookRecip.Resolve Then

                 objOutlookMsg.Display

              End If

              Next

              .Display



           End With

           Set objOutlookMsg = Nothing

           Set objOutlook = Nothing

        End Sub

I appreciate any help you can give me!

Thanks in Advance

Heather


Not finding an answer? Try a Google search.