Hi,
Please modify your code as per the code below-
Sub PopulateCountyDropdown()
Dim AcroApp As Object
Dim AcroAVDoc As Object
Dim AcroForm As Object
Dim CountyField As Object
' Create an instance of Acrobat application
Set AcroApp = CreateObject("AcroExch.App")
' Open the PDF file
Set AcroAVDoc = CreateObject("AcroExch.AVDoc")
If AcroAVDoc.Open("C:\Path\to\your\file.pdf", "") Then
Set AcroForm = AcroAVDoc.GetPDDoc.GetForm
' Get the county field by its name
Set CountyField = AcroForm.Fields("CountyFieldName")
' Set the value of the county field
CountyField.Value = "Perquimans"
' Save and close the PDF file
AcroAVDoc.Save 1, "C:\Path\to\save\output.pdf"
AcroAVDoc.Close True
' Release the objects
Set AcroForm = Nothing
Set AcroAVDoc = Nothing
Set AcroApp = Nothing
End If
End Sub
Replace "CountyFieldName"
with the actual field name of the county drop-down field in your PDF form.
By using the Value
property, you can directly set the desired value for the drop-down field without experiencing the issue you described.
Best Regards.