Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
8

Data via VBA code to PDF form

Participant ,
Sep 13, 2023 Sep 13, 2023

I have been on chat all afternoon with acrobat pro support.  I am sorry, but Adobe really needs to step up the training for their people.  I have been utilizing the following solution on my laptop to get client data from Microsoft Access to a PDF form by filling an xfdf form.  After my code runs I open the xfdf file and I have my nicely filled pdf.

Not working on desktop. Specifically,  the xfdf does fill, because chatgpt (way more helpful than adobe chat) told me to open the xfdf in notepad and see if data was there.  But if I try to open that xfdf file in Acrobat I get the following:  

 

"Adobe could not open ssa1696.pdf because it either not a supported file type or because the file has been damaged (for example it was sent as an email attachment and wasn't correctly encoded.)

To create an Adobe acrobat document, go to the source application.  Then print the document to Adobe PDF"

 

All 3 agents I encountered on chat recited robotically "xfdf is not a supported file".  One had me remove than reinstall Adobe Pro with no change in results.  I think I can have hand-entered the data for 5-6 clients in the time I have spent on this today.

 

 

TOPICS
Create PDFs , Edit and convert PDFs , PDF , PDF forms
1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 13, 2023 Sep 13, 2023

What happens when you open ssa1696.pdf in Acrobat and import the data?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 14, 2023 Sep 14, 2023

If  I open the target pdf form in "prepare form" mode, go to "import data" and select the xfdf file, it will populate my form.  I was hoping for a way to pull this off programmatically.  As it is in the VBA code when I go to the target form nothing has filled and the xfdf will not open in Adobe.  But if I open the xfdf in notepad it has been filled with the data from MS Access.  I think I might be missing a step in the VBA to set the values to the pdf form:

Private Sub Command76_Click()
On Error GoTo ErrHandle
Dim xmlDoc As MSXML2.DOMDocument60
Dim fields As IXMLDOMNodeList, field As IXMLDOMNode
Dim pathToXML As String, myvar As String
Dim ClientMiddle As String
Dim MiddleInitial As String
Dim ClientSSN As String
Dim ClientPhone As String

Set xmlDoc = New MSXML2.DOMDocument60
pathToXML = "C:\Users\stand\Desktop\ssa1696.xfdf"
xmlDoc.Load pathToXML
xmlDoc.SetProperty "SelectionNamespaces", "xmlns:ns='http://ns.adobe.com/xfdf/'"

ClientMiddle = Nz(Me.MiddleName.Value, " ")
ClientMiddleInitial = Left(ClientMiddle, 1)
ClientSSN = Me.SSN.Value
ClientPhone = Me.HomePhone.Value


Set fields = xmlDoc.selectNodes("//ns:field")

For Each field In fields
Select Case field.Attributes.getNamedItem("name").Text

Case "ClientSSN"
field.selectSingleNode("ns:value").Text = Format(ClientSSN, "000-00-0000")

Case "ClientFirstName"
field.selectSingleNode("ns:value").Text = Me.FirstName.Value

Case "ClientMiddleInitial"
field.selectSingleNode("ns:value").Text = ClientMiddleInitial

Case "ClientLastName"
field.selectSingleNode("ns:value").Text = Me.LastName.Value

Case "ClientMailingAddr1"
field.selectSingleNode("ns:value").Text = Me.MailingAddr1.Value

Case "ClientMailingAddr2"
field.selectSingleNode("ns:value").Text = Nz(Me.MailingAddr2.Value)

Case "ClientMailingAddrZip"
field.selectSingleNode("ns:value").Text = Me.Zip.Value

Case "ClientMailingAddrCity"
field.selectSingleNode("ns:value").Text = Me.City.Value

Case "ClientPhone"
field.selectSingleNode("ns:value").Text = Format(ClientPhone, "000-000-0000")

Case "ClientMailingAddrState"
field.selectSingleNode("ns:value").Text = Me.State.Value


End Select
Next field

xmlDoc.Save (pathToXML)
ExitHandle:
Set field = Nothing: Set fields = Nothing: Set xmlDoc = Nothing
Exit Sub

ErrHandle:
MsgBox "Error occurred:" & vbCrLf & _
"Error Number: " & Err.Number & vbCrLf & _
"Description: " & Err.Description & vbCrLf & _
"Source: " & Err.Source & vbCrLf & _
"URL: " & pathToXML, vbCritical
Resume ExitHandle

End Sub

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 14, 2023 Sep 14, 2023
LATEST

This works for me:

  1. I fill a form in Acrobat
  2. I export the data as xfdf
  3. I exit Acrobat
  4. I open the xfdf file in Acrobat
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines