Copy link to clipboard
Copied
Good evening,
I'm trying to read informations about a PDF document from Access in VBA.
I don't understand why I cant read the properties and values from all the fields. The code below does perfectly work except when I try to read properties about the listbox (its a simple choice). When I tried with a multiple choice listbox, I couldnt read the values with numItems and currentValueIndices.
Could you please help me to understand my error ?
I use Access 2010 and Acrobat 2017. My forms has two text fields, one checkbox, two radio buttons and one listbox.
Many thanks
Bruno
Dim apAcrob, apVisuPDDoc, formAcrob As Object
Dim pdfDocument, champsPDF, champEt As Object
Dim nomFichOr As String
Dim lstCaract As String
nomFichOr = "C:\Bruno\ManipPdfAccess\Form_Travail_rempli.pdf"
Set apAcrob = CreateObject("AcroExch.app")
Set apVisuPDDoc = CreateObject("AcroExch.AVDoc")
If apVisuPDDoc.Open(nomFichOr, "Pour lecture des champs") Then
Set formAcrobat = CreateObject("AFormAut.App")
Set champsPDF = formAcrobat.Fields
lstCaract = ""
For Each champEt In champsPDF
lstCaract = lstCaract & "Nom : " & CStr(champEt.Name) & vbCrLf
lstCaract = lstCaract & "Type : " & CStr(champEt.Type) & vbCrLf
lstCaract = lstCaract & "Valeur : " & CStr(champEt.Value) & vbCrLf
Select Case champEt.Type
Case "text"
lstCaract = lstCaract & "Police de caractères : " & CStr(champEt.textFont) & vbCrLf
lstCaract = lstCaract & "Taille de police : " & CStr(champEt.textSize) & vbCrLf
lstCaract = lstCaract & "Justification : " & CStr(champEt.Alignment) & vbCrLf
lstCaract = lstCaract & "Longueur max. : " & CStr(champEt.charlimit) & vbCrLf
Case "listbox"
lstCaract = lstCaract & "Sélection multiple : " & CStr(champEt.multipleSelection) & vbCrLf
End Select
lstCaract = lstCaract & "---------------------" & vbCrLf
Next
MsgBox (lstCaract)
Debug.Print lstCaract
Else
MsgBox ("Pas de document de ce nom disponible")
End If
Set champsPDF = Nothing
Set formAcrobat = Nothing
Set apVisuPDDoc = Nothing
Set apAcrob = Nothing
Copy link to clipboard
Copied
Hi everybody,
Sorry for having set my question, without thinking enough I guess.
I've instantiated a JS object, and I can now read my listbox with mono- or multiple selection in VBA.
Is it helpfull I put the operating code ?
Thanks.
Bruno
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more