Link to home
Start Free TrialLog in
Avatar of Henry Vandersteen
Henry VandersteenFlag for Afghanistan

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.AVDoc")
           
            'Open PDF form
            If acroDoc.Open(strFile, "") Then
                Set pdfDoc = acroDoc.GetPDDoc()
           
               
                'Form fields
                Set jso = pdfDoc.getJSObject
                jso.getfield("fname").Value = Me.txtFName.Value
                jso.getfield("lname").Value = Me.txtLName.Value
                jso.getfield("notes").Value = 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
ASKER CERTIFIED SOLUTION
Avatar of Henry Vandersteen
Henry Vandersteen
Flag of Afghanistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Henry Vandersteen

ASKER

Sorry, i guess I jumped the gun a bit by posting this

I have the answer, see above