从MS Access填充可填写表格PDF

时间:2017-08-19 13:12:51

标签: vba ms-access pdf

我在本网站上发现了一些VBA代码的问题。它是从MS Access填充PDF可填写表单文档中的字段。我尽可能地调整了代码,但仍然出错。

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

我在线上的错误

jso.getField("Form1[0].Pg1[0].fieldName[0].UIDName(0)").Value = "37555-20170517-00001-00023"
  

“运行时错误'424';对象必需”

下面是LiveCycle显示结构的截图。

Structure

0 个答案:

没有答案