ricardus maximus
New member
- Local time
- Yesterday, 23:16
- Joined
- Jan 19, 2024
- Messages
- 6
I'm looping through a data set and populating a pdf with the relevant data and saving the pdfs according to a naming convention.
The issue that I am having is with checking designated "check Boxes" on the pdf . When the pdf is generated it displays the checked box. When it is save... the checked box doesn't persist. I believe this has something to do with the Default value associated with the checkbox. I do not know how to set the default value for the check box programmatically. I would think this is pretty straight forward solution.
The issue that I am having is with checking designated "check Boxes" on the pdf . When the pdf is generated it displays the checked box. When it is save... the checked box doesn't persist. I believe this has something to do with the Default value associated with the checkbox. I do not know how to set the default value for the check box programmatically. I would think this is pretty straight forward solution.
Code:
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_Reports\"
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 'This is the portion of the code that doesn't persist.
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
End Sub