嗨,所有这些代码在从 Excel 工作表中填写 VA 28-1905 表格时都非常有效。但是,复选框不会保持选中状态。它们在表单最初保存时被选中,但是当您再次打开它时,复选框不会被选中。我不知道如何解决这个问题。任何帮助,将不胜感激。我不是一直都在编程,所以如果你有改进建议也会很棒。
我尝试了 objJSO.flattenpages 但我得到了 NotAllowedError: Security settings prevent access to this property or method。如果我在保存之前停止代码,所有内容都正确填写,但保存后复选框重置为 0。
此代码改编自 Christos Samaras 的代码。
'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