Reputation: 1
Hi All this code works wonderfully in filling out a VA 28-1905 form from a worksheet in excel. However the checkboxes don't remain checked. They are checked when the form initially saves, but when you open it again then the checkboxes aren't check. I don't know how to resolve this. Any help would be appreciated. I don't program all of the time so if you have improvement suggestions that would be awesome as well.
I tried objJSO.flattenpages but I get a NotAllowedError: Security settings prevent access to this property or method. If I stop the code before the save everything is filled out properly, but after save the checkboxes reset to 0.
This code has been adapted from Christos Samaras' code.
'Enable screen flickering.
Application.ScreenUpdating = True
' 'All checkboxes to checked
objAcroApp.Show
objJSO.GetField(strFieldNames(22)).Value = 1
objJSO.GetField(strFieldNames(23)).Value = 1
objJSO.GetField(strFieldNames(24)).Value = 1
objJSO.GetField(strFieldNames(25)).Value = 1
objJSO.GetField(strFieldNames(26)).Value = 1
objJSO.GetField(strFieldNames(27)).Value = 1
objJSO.GetField(strFieldNames(28)).Value = 1
objJSO.GetField(strFieldNames(52)).Value = 1
'Veteran's Vocation Choice set focus
objAcroApp.Show
objJSO.GetField(strFieldNames(5)).SetFocus
Application.Wait Now + 0.00001
'Application.SendKeys "{Tab}", True
Application.SendKeys "{right}", True
'Create the output path with the term and class .pdf
Dim w
If x = 4 Then
w = LastRow
Else
w = x - 1
End If
refFile = "\" & oSheet & "." & w & ".pdf"
strPDFOutPath = strPDFOutPath & refFile
'Save the form as new PDF file.
objAcroPDDoc.Save 2, strPDFOutPath
'Close the form without saving the changes.
objAcroAVDoc.Close True
'Close the Acrobat application.
objAcroApp.Exit
'Release the objects.
Set objJSO = Nothing
Set objAcroPDDoc = Nothing
Set objAcroAVDoc = Nothing
Set objAcroApp = Nothing
Else
MsgBox "Could not open the file!", vbCritical, "File error"
'Close the Acrobat application.
objAcroApp.Exit
'Release the objects and exit.
Set objAcroAVDoc = Nothing
Set objAcroApp = Nothing
Exit Sub
End If
i = w
Next i
End With
Next p
'Inform the user that forms were filled.
MsgBox "All forms were created successfully!", vbInformation, "Finished"
End Sub
Upvotes: 0
Views: 581