问题
Having a problem with some VBA code I found on this site. It is to populate a field in a PDF fillable form document from MS Access. I adjusted the code best I could, but still getting an error.
Dim strTemplate, strPath, strDir, gApp, avDoc, pdDoc, jso
strPath = Left(CurrentDb.Name, InStrRev(CurrentDb.Name, "\"))
strDir = Left(CurrentDb.Name, InStrRev(CurrentDb.Name, "\"))
strDir = strDir & "Plans\" & Form_Plan_Frm!Cage & "\" & Form_Plan_Frm!UID
strTemplate = strPath & "Templates\test.pdf"
Set gApp = CreateObject("AcroExch.app")
Set avDoc = CreateObject("AcroExch.AVDoc")
If avDoc.Open(strTemplate, "") Then
Set pdDoc = avDoc.GetPDDoc()
Set jso = pdDoc.GetJSObject
jso.getField("Form1[0].Pg1[0].Topinfo[0].UIDName[0]").Value = "37555-20170517-00001-00023"
pdDoc.Save PDSaveIncremental, "Test.pdf" 'Save changes to the PDF document
pdDoc.Close
End If
avDoc.Close (True)
Set gApp = Nothing
Set avDoc = Nothing
Set pdDoc = Nothing
Set jso = Nothing
The error I am getting on the line
jso.getField("Form1[0].Pg1[0].fieldName[0].UIDName(0)").Value = "37555-20170517-00001-00023"
"Run time error '424'; Object Required"
Below is a screenshot of what LiveCycle shows for the structure.
来源:https://stackoverflow.com/questions/45771955/populate-fillable-form-pdf-from-ms-access