Results 1 to 4 of 4
  1. #1
    jlnewnam is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2013
    Location
    Phoenix, AZ
    Posts
    2

    Lightbulb Button that opens fillable PDF and pre-fills necessary fields...

    I have a database already created to monitor the flow of scholarships for a University. This is a small scholarship program, so we're using Access to maintain everything.

    I have one form labeled 'Contributor'. On that form, there are 3 different tabs.

    Tab 1: Collects general information – Company Name, Business Phone, Email Address
    Tab 2: Collects more detailed information – First/Last Name, Address, Phone, etc
    Tab 3: Collects the actual donation information – the most important being the amount donated.

    I have created a link on the form to bring up a PDF form stored on the database. The PDF doc is simply a receipt for tax write-off purposes for the donation.

    What I’m trying to do is…

    1. When the Donation Receipt comes up, I want certain information from the ‘Contributor’ form (in Access) to populate in the PDF form.
    2. Then have the ability to save the form to the database, having relation to the contributor.
    3. Click a button to send that form, via email, to the contributor for their records.


    Does that make sense?



    -Jared

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Google: Access vba fill in pdf form

    http://stackoverflow.com/questions/1...-vba-ms-access
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    jlnewnam is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2013
    Location
    Phoenix, AZ
    Posts
    2
    Thanks June7. I appreciate this. I've posted the answer below, in hopes that you or someone else can maybe explain a step-by-step on how to implement this script.

    Thoughts?

    ----------------------------------------------------------
    Finally managed to get something working after merging some lines of code. Here it is. It works with the Adobe Acrobat 9.0 Type Library set as reference in my VBA project.

    Code:
    Dim FileNm, gApp, avDoc, pdDoc, jso
    
    FileNm = "c:\form.pdf" 'File location
    Set gApp = CreateObject("AcroExch.app")
    
    Set avDoc = CreateObject("AcroExch.AVDoc")
    If avDoc.Open(FileNm, "") Then
        Set pdDoc = avDoc.GetPDDoc()
        Set jso = pdDoc.GetJSObject
    
        jso.getField("topmostSubform[0].Page1[0].fieldName[0]").value = "myValue"
        pdDoc.Save PDSaveIncremental, FileNm 'Save changes to the PDF document
        pdDoc.Close
    End If
    
    'Close the PDF; the True parameter prevents the Save As dialog from showing
    avDoc.Close (True) 
    
    'Some cleaning
    Set gApp = Nothing
    Set avDoc = Nothing
    Set pdDoc = Nothing
    Set jso = Nothing
    Note that topmostSubform[0].Page1[0] is the default name that Adobe LiveCycle Designer gives to your main PDF document, while fieldName[0] is the name of your field. If you have multiple fields with the same name, Adobe LiveCycle Designer automatically adds index numbers so you can easily loop through your fields.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Customize to your situation. Use your file path, file names, fieldnames, etc.

    I have no idea what the .GetJSObject is all about.

    I have no idea if the code will work. I don't have a PDF form to test with.

    Here is another link http://www.vbaexpress.com/forum/showthread.php?t=21503
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. button that opens form
    By rwest in forum Forms
    Replies: 3
    Last Post: 01-06-2012, 11:59 AM
  2. Replies: 2
    Last Post: 09-11-2011, 05:19 AM
  3. Combo Box Fills another field
    By tcheck in forum Access
    Replies: 7
    Last Post: 06-30-2011, 11:49 AM
  4. Replies: 3
    Last Post: 05-28-2011, 09:54 PM
  5. Form opens differently from control button
    By bdaniel in forum Programming
    Replies: 5
    Last Post: 12-29-2009, 12:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums