Hi,
I'm having a issue getting the fields from a PDF file created in Livecycle. I get the following error once I access a field:
Element not found. (Exception from HRESULT: 0x8002802B (TYPE_E_ELEMENTNOTFOUND))
Is it possible to use the OLE API's to retreive the fields in the Livecycle form? Here is the code in question:
Public Function FillForm(ByVal patient As clsPatient, ByVal isNew As Boolean, Optional ByVal CompletionDate As Date = #1/1/1900#) As String Implements iPDFProcess.FillForm
Dim ds As New DataSet
Dim dr As DataRow
Dim NewFile As String
Dim formApp As AFORMAUTLib.AFormApp
Dim bOK As Boolean
Dim avDoc As Acrobat.CAcroAVDoc
Dim pdDoc As Acrobat.CAcroPDDoc
Try
'Set the mouse icon to display an hourglass
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor
If isNew = False Then
ds = GetData(PatientId, CompletionDate)
If ds.Tables(0).Rows.Count > 0 Then
dr = ds.Tables(0).Rows(0)
End If
End If
avDoc = CreateObject("AcroExch.AVDoc")
bOK = avDoc.Open(lTemplateFileName, "NB")
avDoc.Maximize(1)
formApp = CreateObject("AFormAut.App")
If isNew = True Then 'Only fill Demographic data
formApp.Fields("PatientId").value = patient.PatientId
formApp.Fields("DateCompleted").value = Format(Now(), "M/dd/yyyy")
formApp.Fields("PatientName").value = patient.LastName & ", " & patient.FirstName
end if
The rest of the code is not shown to save room.
As soon it tried to access a field I get the above error. I also have a problem with the following code in another section of my code (for another PDF form). Here is a segment of the code:
avDoc = CreateObject("AcroExch.AVDoc")
bOK = avDoc.Open(lTemplateFileName , "NB")
avDoc.Maximize(1)
formApp = CreateObject("AFormAut.App")
acroForm = formApp.Fields
If isNew = True then
For Each f As AFORMAUTLib.Field In acroForm
Select Case f.Name
Case "PatientName"
f.Value = patient.LastName & ", " & patient.FirstName
Case "Gender"
f.Value = patient.Gender
Case "DateCompleted"
f.Value = format(Now(), "M/dd/yyyy")
Case "PatientId"
f.Value = patient.PatientId
Case "DOB"
f.Value = patient.BirthDate
End Select
Next
Else
It always passes right over the loop as it it can't find the fields. What up with that. Thanks for any help that you can provide.
1. How can I represent a Date picker field?
2. A few of our forms created in Livecycle use dynamic forms. I.E. Hiding pages until a checkbox is selected for example. Is it possible to get similar results with just Acrobat/reader?
Thanks for any suggestion or comments.