我怎样才能正确调试这段代码??? (Set AcroApp = CreateObject("AcroExch.App") 中的问题)

问题描述 投票:0回答:1

我有这个代码,我需要影响具有访问权限的书签 pdf 的值。 我安装了 Adobe Acrobat 10.0 Type Library 并勾选了 但是,当我执行代码时,我在 Set Aapp = CreatObject("AcroExch.App") 行上收到以下错误。

运行时错误'-2146959355 (80080005)':不支持此类接口。

任何人都知道导致此问题的原因以及如何解决它。

Private Sub Btn_Click()


    Dim bookmarks As Object
    Dim bookmark As Object
    
    ' Déclaration des variables
    Dim AcroApp As Object ' Objet Application Acrobat
    Dim AcroAVDoc As Object ' Objet Document Acrobat
    Dim AcroPDDoc As Object ' Objet Document PDF
    Dim i As Integer
    Dim fichierPDF As String
    
    fichierPDF = "C:\Users\jhamchaoui\Desktop\print.pdf"
    
    ' Ouvrir le fichier PDF
    Set AcroApp = CreateObject("AcroExch.App")
    Set AcroAVDoc = CreateObject("AcroExch.AVDoc")
    
    If AcroAVDoc.Open(fichierPDF, "") Then
        Set AcroPDDoc = AcroAVDoc.GetPDDoc
        
        ' Obtenir les signets
        Set bookmarks = AcroPDDoc.GetBookmarks
        For Each bookmark In bookmarks
            If bookmark.Title = "date" Then
                bookmark.SetValue "Jigo"
            ElseIf bookmark.Title = "serv" Then
                bookmark.SetValue "HAMC"
            End If
        Next bookmark
        
        ' Enregistrer les modifications dans le fichier PDF
        AcroPDDoc.Save 1, fichierPDF
        
        ' Fermer le document
        AcroPDDoc.Close
        
        ' Fermer le document AVDoc
        AcroAVDoc.Close 1
    End If

    ' Libérer les objets
    Set bookmarks = Nothing
    Set AcroPDDoc = Nothing
    Set AcroAVDoc = Nothing
    Set AcroApp = Nothing


End Sub
excel vba ms-access pdf
1个回答
0
投票

请选择 Adobe acrobat。 Algo que no requiera de mucho peso y/o trabajo de instalación previo.

© www.soinside.com 2019 - 2024. All rights reserved.