Participant
January 22, 2024
Question
update a checkbox vba java script
- January 22, 2024
- 1 reply
- 635 views
Hi everyone.
I'm attempting to prepopulate an IRS Form 1041 for a population. I am able to populate the text fields fine, but the checkboxes show as checked but when the form is saved the checked box doesn't persist.
Private Sub Command8_Click()
Dim FileNm As String
Dim FileNm2 As String
Dim aApp As Acrobat.AcroApp
Dim aAVDoc As Acrobat.AcroAVDoc
Dim aPDDoc As Acrobat.AcroPDDoc
Dim JSO As Object 'There is no explicit class type for the JSObject
FileNm = "\\its\fss\Plans\PEO-MEP\RichAnthony\EditPDF\IRS Form 1041_2023.pdf"
FileNm2 = "\\its\fss\Plans\PEO-MEP\RichAnthony\EditPDF\1041_Reports2\"
Set aApp = CreateObject("AcroExch.App")
Set aAVDoc = CreateObject("AcroExch.AVDoc")
If aAVDoc.Open(FileNm, "") Then
Set aPDDoc = aAVDoc.GetPDDoc()
Set JSO = aPDDoc.GetJSObject()
'Debugging - output all fields
' For i = 0 To JSO.numFields - 1
' Set Field = JSO.getField(JSO.getNthFieldName(i))
' Debug.Print i, Field.Name, Field.Value, Field.Type, Field.Page
' Next
' MsgBox "This is a pause."
'Create Result set
Dim rs As Object, strSql As String, GroupAccount As String
Dim FilePath As String, FileName As String, Criteria As String
Dim xFilePrefix As String
Dim xBegDate As String
Dim xEndDate As String
Dim xYrEnd As String
Dim xPlanName As String
Dim xTrustCompany As String
Dim xTrustCompanyaddress1 As String
Dim xTrustCompanyaddress2 As String
Dim xOTC_EFF_DATE As String
Dim xEIN As String
Dim xFiduciaryEIN As String
xBegDate = "JANUARY 01"
xEndDate = "DECEMBER 31"
xYtEnd = "23"
xTrustCompany = "EMPOWER TRUST COMPANY LLC"
xTrustCompanyaddress1 = "8525 E. ORCHARD RD 8T3"
xTrustCompanyaddress2 = "GREENWOOD VILLAGE, CO 80111-5002"
xFiduciaryEIN = "84-1455663"
xFilePrefix = "IRS 1041 "
'FilePath = SelectFolder & "\" This will be used to navigate to where the 1041 output will be dropped.
Set rs = CreateObject("ADODB.Recordset")
strSql = "Select * FROM [Tbl Plan Data];"
rs.Open strSql, CurrentProject.Connection
Do While Not rs.EOF
GroupAccount = rs![Group Account]
xPlanName = rs![Plan Name]
xOTC_EFF_DATE = rs![OTC_Effective_Date] 'Need to add to table.
If IsNull(rs![Trust EIN]) Then
xEIN = ""
Else
xEIN = rs![Trust EIN] 'Need to add to table.
End If
rs.MoveNext
FileName = FileNm2 & xFilePrefix & " " & GroupAccount & ".pdf"
Criteria = "[Group Account] = '" & GroupAccount & "'"
JSO.getField("topmostSubform[0].Page1[0].DateNameAddress_ReadOrder[0].f1_1[0]").Value = xBegDate
JSO.getField("topmostSubform[0].Page1[0].DateNameAddress_ReadOrder[0].f1_2[0]").Value = xEndDate
JSO.getField("topmostSubform[0].Page1[0].DateNameAddress_ReadOrder[0].f1_3[0]").Value = xYtEnd
JSO.getField("topmostSubform[0].Page1[0].DateNameAddress_ReadOrder[0].f1_4[0]").Value = xPlanName
JSO.getField("topmostSubform[0].Page1[0].DateNameAddress_ReadOrder[0].f1_5[0]").Value = xTrustCompany
JSO.getField("topmostSubform[0].Page1[0].DateNameAddress_ReadOrder[0].f1_6[0]").Value = xTrustCompanyaddress1
JSO.getField("topmostSubform[0].Page1[0].DateNameAddress_ReadOrder[0].f1_7[0]").Value = xTrustCompanyaddress2
JSO.getField("topmostSubform[0].Page1[0].LinesC-E[0].f1_10[0]").Value = xOTC_EFF_DATE
JSO.getField("topmostSubform[0].Page1[0].LinesC-E[0].f1_9[0]").Value = xEIN
JSO.getField("topmostSubform[0].Page1[0].SignatureDate_ReadOrder[0].SignatureDate_ReadOrder[0].f1_47[0]").Value = xFiduciaryEIN
JSO.getField("topmostSubform[0].Page1[0].LinesA-B[0].c1_6[0]").Value = 1
aPDDoc.Save PDSaveIncremental, FileName 'Save changes to the PDF document
Loop
aPDDoc.Close
End If
'Close the PDF; the True parameter prevents the Save As dialog from showing
aAVDoc.Close (True)
rs.Close
'Some cleaning
Set aAVDoc = Nothing
Set aPDDoc = Nothing
Set JSO = Nothing
Set rs = Nothing
MsgBox "Merge Process Complete."
End Sub
