【发布时间】:2017-06-09 12:25:37
【问题描述】:
我想使用从 Access 报告中提取的数据填充 Adobe Fillable 表单。我将不胜感激有关如何使此代码正常工作的一些建议。我对 VBA 比较陌生,所以我最大的问题来自代码的哪一部分是 Adobe,哪一部分来自 Access 字段。
我的一些访问字段名称是:Payee Extended_Payee、Check Request Date、Invoice Number 等。 我在 Adobe 表单中的一些字段名称是:Payee、Today's Date、Invoice Number 等。
这是我到目前为止的编码 - 我想澄清一下代码的哪一部分应该反映 adobe 字段,哪一部分应该来自 Access :
Private Sub Export_Click()
Dim FileNm, gApp, avDoc, pdDoc, jso
FileNm = "M:\Check_Requests\2017\PDF_Exports\CheckForm.pdf" 'File location
Set gApp = CreateObject("AcroExch.app")
Set avDoc = CreateObject("AcroExch.AVDoc")
FileCopy FileNm, newFileNm
If avDoc.Open(newFileNm, "") Then
Set pdDoc = avDoc.GetPDDoc()
Set jso = pdDoc.GetJSObject
jso.getField("CheckForm[0].Page1[0].Payee[0]").Value = "Payees_Extended_Payee"
jso.getField("CheckForm[0].Page1[0].Address[0]").Value = "Address"
jso.getField("CheckForm[0].Page1[0].City[0]").Value = "City"
jso.getField("CheckForm[0].Page1[0].State[0]").Value = "State"
jso.getField("CheckForm[0].Page1[0].Zip_Code[0]").Value = "Zip_Code"
jso.getField("CheckForm[0].Page1[0].Comments_to_Include_on_Remittance[0]").Value = "Description_of_Expense"
jso.getField("CheckForm[0].Page1[0].Todays_Date[0]").Value = "Check_Request_Date"
jso.getField("CheckForm[0].Page1[0].Invoice_Number[0]").Value = "Invoice_Number"
jso.getField("CheckForm[0].Page1[0].Invoice_Date[0]").Value = "Invoice_Date"
jso.getField("CheckForm[0].Page1[0].Total_Amount[0]").Value = "Total_Amount"
jso.getField("CheckForm[0].Page1[0].Description_of_Expense[0]").Value = "Description_of_Expense"
jso.getField("CheckForm[0].Page1[0].Other[0]").Value = "Other"
jso.getField("CheckForm[0].Page1[0].GL1[0]").Value = "GL_Company"
jso.getField("CheckForm[0].Page1[0].AU1[0]").Value = "Accounting Unit"
jso.getField("CheckForm[0].Page1[0].A1[0]").Value = "Account"
jso.getField("CheckForm[0].Page1[0].CODE1[0]").Value = "Project_Code"
jso.getField("CheckForm[0].Page1[0].AMOUNT1[0]").Value = "Amount_Split_1"
jso.getField("CheckForm[0].Page1[0].GL2[0]").Value = "GL_Company_2"
jso.getField("CheckForm[0].Page1[0].AU2[0]").Value = "Accounting_Unit_2"
jso.getField("CheckForm[0].Page1[0].A2[0]").Value = "Account_2"
jso.getField("CheckForm[0].Page1[0].CODE2[0]").Value = "Project_Code_2"
jso.getField("CheckForm[0].Page1[0].AMOUNT2[0]").Value = "Amount_Split_2"
jso.getField("CheckForm[0].Page1[0].GL3[0]").Value = "GL_Company_3"
jso.getField("CheckForm[0].Page1[0].AU3[0]").Value = "Accounting_Unit_3"
jso.getField("CheckForm[0].Page1[0].A3[0]").Value = "Account_3"
jso.getField("CheckForm[0].Page1[0].CODE3[0]").Value = "Project_Code_3"
jso.getField("CheckForm[0].Page1[0].AMOUNT3[0]").Value = "Amount_Split_3"
jso.getField("CheckForm[0].Page1[0].Total[0]").Value = "Amount_Total"
jso.getField("CheckForm[0].Page1[0].Requestor[0]").Value = "Requestor"
jso.getField("CheckForm[0].Page1[0].Approving Manager[0]").Value = "Approving_Manager"
jso.getField("CheckForm[0].Page1[0].Extension[0]").Value = "Extension"
jso.getField("CheckForm[0].Page1[0].Email_Address[0]").Value = "Email_Address"
pdDoc.Save PDSaveIncremental, FileNm 'Save changes to the PDF document
pdDoc.Close
End If
'Close the PDF; the True parameter prevents the Save As dialog from showing
avDoc.Close (True)
'Some cleaning
Set gApp = Nothing
Set avDoc = Nothing
Set pdDoc = Nothing
Set jso = Nothing
End Sub
【问题讨论】: