Henry Vandersteen
asked on
How to flatten fillable PDF Form and save using Access
Hi
I have some code I got off the internet which allows me to populate a PDF Form with data from Access. However, it doesnt allow me to flatten the form and save so the fields are no longer editable. Not sure how to do that. Heres the code
Dim acroApp As Object
Dim acroDoc As Object
Dim pdfDoc As Object
Dim jso As Object
Dim PDSaveIncremental As Variant
Dim strFile As String, strFileSeqNum As String
'Fillable PDF filename and location
strFile = CurrentProject.Path & "\" & "Template.pdf"
' strFileSeqNum = CurrentProject.Path & "\" & "12345.pdf"
'Check for the PDF
If Dir(strFile) = "" Then
MsgBox "This demo requires the PDF form (Template.pdf).", vbInformation, "Missing PDF"
Else
'Create Acrobat object
Set acroApp = CreateObject("AcroExch.App ")
Set acroDoc = CreateObject("AcroExch.AVD oc")
'Open PDF form
If acroDoc.Open(strFile, "") Then
Set pdfDoc = acroDoc.GetPDDoc()
'Form fields
Set jso = pdfDoc.getJSObject
jso.getfield("fname").Valu e = Me.txtFName.Value
jso.getfield("lname").Valu e = Me.txtLName.Value
jso.getfield("notes").Valu e = Me.txtNotes.Value
'Save changes to the PDF document
pdfDoc.Save PDSaveIncremental, strFile
' pdfDoc.Save PDSaveIncremental, strFileSeqNum
'Close the PDF; the True parameter prevents the Save As dialog from showing
acroDoc.Close (True)
'View the PDF file
ShellEx strFile
' ShellEx strFileSeqNum
' MsgBox "Done"
End If
Set acroApp = Nothing
Set acroDoc = Nothing
Set pdfDoc = Nothing
thanks for your help
H
I have some code I got off the internet which allows me to populate a PDF Form with data from Access. However, it doesnt allow me to flatten the form and save so the fields are no longer editable. Not sure how to do that. Heres the code
Dim acroApp As Object
Dim acroDoc As Object
Dim pdfDoc As Object
Dim jso As Object
Dim PDSaveIncremental As Variant
Dim strFile As String, strFileSeqNum As String
'Fillable PDF filename and location
strFile = CurrentProject.Path & "\" & "Template.pdf"
' strFileSeqNum = CurrentProject.Path & "\" & "12345.pdf"
'Check for the PDF
If Dir(strFile) = "" Then
MsgBox "This demo requires the PDF form (Template.pdf).", vbInformation, "Missing PDF"
Else
'Create Acrobat object
Set acroApp = CreateObject("AcroExch.App
Set acroDoc = CreateObject("AcroExch.AVD
'Open PDF form
If acroDoc.Open(strFile, "") Then
Set pdfDoc = acroDoc.GetPDDoc()
'Form fields
Set jso = pdfDoc.getJSObject
jso.getfield("fname").Valu
jso.getfield("lname").Valu
jso.getfield("notes").Valu
'Save changes to the PDF document
pdfDoc.Save PDSaveIncremental, strFile
' pdfDoc.Save PDSaveIncremental, strFileSeqNum
'Close the PDF; the True parameter prevents the Save As dialog from showing
acroDoc.Close (True)
'View the PDF file
ShellEx strFile
' ShellEx strFileSeqNum
' MsgBox "Done"
End If
Set acroApp = Nothing
Set acroDoc = Nothing
Set pdfDoc = Nothing
thanks for your help
H
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have the answer, see above