0
我喜歡使用從Access報告中提取的數據填充Adobe可填寫表單。我將不勝感激關於如何讓此代碼工作的一些建議。我對VBA相對比較陌生,所以我最大的問題將來自代碼的哪部分是Adobe,哪部分來自Access字段。將可訪問報告導出爲PDF可填寫表單
我的一些訪問字段名:收款人Extended_Payee,檢查請求日期,發票號碼等 一些在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
非常感謝你對亞歷山大的迴應!我很抱歉,但我只想確保我很清楚。我需要在開始時用我的代碼更改任何內容嗎?我希望能夠點擊Access報表上的按鈕,打開PDF表單模板,填寫報表中的所有數據,然後保存爲特定於該發票的文件[Payee Payee_Extended] + [Invoice_Number] + [Check_Request_Date] – pthomas
我已經更新了代碼,如下所示: – pthomas
它看起來像你這樣做對我來說是正確的,只不過每次點擊你填寫並保存相同的PDF文件。要編輯新文件,您必須將文件複製到新的位置/名稱並從此處打開。您可以在Open之前添加 'FileCopy FileNm,newFileNm'然後用 開啓新文件'如果avDoc.Open(newFileNm,「」)然後' –