• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1379
  • Last Modified:

How do I merge data from access to a pdf form? I have other PDF related questions too.


I'm familiar with Access, however, I know very little about PDFs, and how to merge Access data onto them. I'm currently using Access 2003 and Adobe Acrobat Professional 7.0. I would prefer not to purchase a 3rd party software if I don't have to.

Currently I have several stand alone Fillable pdf forms that the users fill out and save. What I want to do is prepolulate most of data for them from an Access database.  

Here are some of the questions I have:
1. How do I filter out just the record they want? Can you link a PDF to a parameter query?
2. If I have 50 records in my access table, how do I merge all 50 records to an exisiting pdf form? Like a Word mail merge.
3. Once the merge is complete, can you save the new merged pdf so that it is no longer attached to the database?

Thanks for all of your help. I appreciate it. Please include code samples if appropriate.  
0
NLGroup
Asked:
NLGroup
  • 3
  • 2
1 Solution
 
Kelvin SparksCommented:
Do all 50 records go into the forms creating 50 forms - if so, do you have a naming convention for them?

The code itself is not too difficult, and I'm guessing you keep a blank form as a master, populate with record 1 and save to a name, then loop to 2 etc....


Kelvin
0
 
NLGroupAuthor Commented:
Kelvin, thanks for your response.

I was thinking of just merging them and printing them. I had not thought about saving them.

Right now, my one PDF is linked to the table with the 50 records. I linked it with the Forms Designer. Can I just merge and print?
0
 
Kelvin SparksCommented:
If you have the blank pdf with the fields on it, the you can, with the use of a bit of code, populate the fields and print them. In all cases where I've done it before, we had to keep a copy so, they we saved first. In that case, we even went as far as creating the field on a blank pdf, then populating them.

Kelvin
0
 
NLGroupAuthor Commented:
Do you have some sample code?
0
 
Kelvin SparksCommented:
You need to set references to Adoble type libraries. When I did this last it was adobe 5.0 and they were set to the Adobe Acrobat 5.0 Type library  and AFormAut 1.0 Type library (in the Reader plugins folder somewhere)

Function would go something like this

Note thios piece of code was to add a new field - you may want to edit an existing field

    Dim PDDoc As CAcroPDDoc
    Dim formApp As AFORMAUTLib.AFormApp
    Dim acroForm As AFORMAUTLib.Fields
    Dim field As AFORMAUTLib.field
    Dim AVDoc As CAcroAVDoc
    Dim bOk As Boolean

    Set AVDoc = CreateObject("AcroExch.AVDoc")
    While Not bOk
        bOk = AVDoc.Open(sFileName, "")
    Wend
   
    Set PDDoc = AVDoc.GetPDDoc
    Set formApp = CreateObject("AFormAut.App")
    Set acroForm = formApp.Fields
   
    Set field = acroForm.Add(sFieldName, "text", 0, 0, 35, 510, 0)
    field.IsHidden = False
    field.Value = sFieldValue  'parameter with test field's data
    field.TextSize = "9"
    field.TextFont = "Arial"
       
    If Not PDDoc.Save(PDSaveFull, sFileName) Then
        MsgBox "Unable to Save the PDF file (" & sFileName & ")"
    End If
   
    If Not AVDoc.Close(True) Then
        MsgBox "Unable to close the PDF file (" & sFileName & ")"
    End If

ex:
    Set PDDoc = Nothing ' Free the called object
    Set formApp = Nothing
    Set acroForm = Nothing
    Set field = Nothing
    Set AVDoc = Nothing
    Exit Sub
er:
    GoTo ex
    Exit Sub


0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now