2
× dnLL 639 1 4 27 1 Answer dnLL 639 1 4 27 I want to fill a PDF form from my MS-Access 2003 .mdb project. The PDF has been created with Adobe LifeCycle Designer ES 8.2, all fields have significant names. However, the users who will run the PDf-filling functionnality don't have LifeCycle installed but only Adobe Reader 9.5 instead (might migrate to Adobe Reader X soon, I would like my code to be a little bit future proof). How can I implement this? Most threads that I've seen on the Web redirect to the official Adobe SDK documentation, which is completely a mess when you're only doing VBA. Thank you. vba ms-access pdf pdf-form edited Nov 13 '12 at 16:45 asked Nov 13 '12 at 13:56 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. 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. edited Dec 11 '12 at 20:20 answered Nov 13 '12 at 15:10 Not the answer you're looking for? Browse other questions tagged vba ms-access pdf pdf-form or ask your own question. Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required. Fill in a PDF form from VBA (MS-Access) Fill in a PDF form from VBA (MS-Access) - Stack Overflow http://stackoverflow.com/questions/13362014/fill-in-a-pdf-form-from-... 1 of 2 10/9/2013 5:05 PM

Fill in a PDF form from VBA (MS-Access)

  • Upload
    cafjnk

  • View
    127

  • Download
    2

Embed Size (px)

DESCRIPTION

Fill in a PDF form from VBA (MS-Access)

Citation preview

Page 1: Fill in a PDF form from VBA (MS-Access)

×

dnLL639 1 4 27

1 Answer

dnLL639 1 4 27

I want to fill a PDF form from my MS-Access 2003 .mdb project. The PDF has been created with AdobeLifeCycle Designer ES 8.2, all fields have significant names. However, the users who will run the PDf-fillingfunctionnality don't have LifeCycle installed but only Adobe Reader 9.5 instead (might migrate to AdobeReader X soon, I would like my code to be a little bit future proof).

How can I implement this? Most threads that I've seen on the Web redirect to the official Adobe SDKdocumentation, which is completely a mess when you're only doing VBA.

Thank you.

vba ms-access pdf pdf-form

edited Nov 13 '12 at 16:45 asked Nov 13 '12 at 13:56

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

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 yourmain PDF document, while fieldName[0] is the name of your field. If you have multiple fields with thesame name, Adobe LiveCycle Designer automatically adds index numbers so you can easily loop throughyour fields.

edited Dec 11 '12 at 20:20 answered Nov 13 '12 at 15:10

Not the answer you're looking for? Browse other questions tagged vba ms-access pdf

pdf-form or ask your own question.

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, noregistration required.

Fill in a PDF form from VBA (MS-Access)

Fill in a PDF form from VBA (MS-Access) - Stack Overflow http://stackoverflow.com/questions/13362014/fill-in-a-pdf-form-from-...

1 of 2 10/9/2013 5:05 PM

Page 2: Fill in a PDF form from VBA (MS-Access)

Fill in a PDF form from VBA (MS-Access) - Stack Overflow http://stackoverflow.com/questions/13362014/fill-in-a-pdf-form-from-...

2 of 2 10/9/2013 5:05 PM