0

こんにちは、このコードはすべて、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
4

0 に答える 0