Précédent   Forum des professionnels en informatique > Logiciels > Microsoft Office > Général VBA
Général VBA Forum général VBA . Pour les logiciels spécifiques (Access, Excel, Word, ...), postez dans les bons sous forums.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 03/10/2007, 18h18   #1
Invité de passage
 
Inscription : novembre 2006
Messages : 23
Détails du profil
Informations forums :
Inscription : novembre 2006
Messages : 23
Points : 4
Points : 4
Par défaut VBA 6.3 et Acrobat Professionnel 7

Bonjour,

Je manipule actuellement, en VBA, un fichier pdf dans Acrobat Professionnel 7.
J'essaye de créer un lien entre deux pages d'un fichier pdf en VBA.
Manuellement, il faut faire les manipulations ci-dessous:
1- Outils\Modifications avancées\Lien
2- Créer un rectangle avec la souris
3- Cliquer sur "Suivant" lors de l'affichage de la fenêtre "Créer un lien"
4- Cliquer sur "Définir le lien" lors de l'affichage de la fenêtre "Créer Atteindre la vue"
5- Se positionner sur le rectangle créé avec la souris,
6- Click droit
7- Sélectionner "Propriétés..." dans le menu contextuel,
8- Cliquer sur "Modifier" pour changer la page à atteindre,
9- Changer le n° de page dans la fenêtre "Atteindre une page du document",
10- Sélectionner l'option "Héritier du zoom" dans la partie "zoom" de la fenêtre "Atteindre une page du document",
11- Cliquer sur le bouton "ok",
12- Cliquer sur le bouton "Fermer"

En VBA, j'arrive à créer le rectangle mais pas à paramétrer la suite.

Pouvez-vous m'aider?

Ci-dessous mon code.

Cordialement,

Arnaud

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
 
 
Sub adobe()
 
Dim AcrApp As Acrobat.AcroApp 'Application Acrobat
 
Dim AcrAvDoc As Acrobat.AcroAVDoc 'Document actif dans Acrobat
Dim AcrPdDoc As Acrobat.AcroPDDoc
 
Dim AcrAvPv As Acrobat.AcroAVPageView 'Page active dans Acrobat
Dim AcrAvPv2 As Acrobat.AcroAVPageView 'Page destination dans Acrobat
Dim AcrPdP As Acrobat.AcroPDPage 'Page active dans Acrobat
 
'Dim acrtext As Acrobat.AcroPDTextSelect
Dim AcrRect As Acrobat.AcroRect
Dim AcrPdTSel As Acrobat.AcroPDTextSelect
Dim AcrPdAnnot As Acrobat.AcroPDAnnot
Dim acrtitle As String
Dim acrtool As String
Dim nbannots As Long
Dim texte As String
Dim contents As Variant
Dim AcrPdAnnot2 As Acrobat.AcroPDAnnot
 
Set AcrApp = New Acrobat.AcroApp
    Set AcrAvDoc = AcrApp.GetActiveDoc
        acrtitle = AcrAvDoc.GetTitle
        Debug.Print acrtitle 'Permet d'afficher le titre du document
        Set AcrAvPv = AcrAvDoc.GetAVPageView
            AcrAvPv.Goto 0 'Va en page 1
            Debug.Print AcrAvPv.GetPageNum
            AcrApp.SetActiveTool "Link", 1 'Passe en mode Link
            acrtool = AcrApp.GetActiveTool
            Set AcrPdP = AcrAvPv.GetPage
                nbannots = AcrPdP.GetNumAnnots
                Set AcrPdAnnot = AcrPdP.GetAnnot(0)
                    Set AcrRect = AcrPdAnnot.GetRect
                        texte = ""
                        texte = texte & AcrRect.Left & "," & 839 - AcrRect.Top & "    -     " & AcrRect.Right & "," & 839 - AcrRect.bottom & vbCr
                        texte = texte & AcrPdAnnot.GetColor & vbCr
                        texte = texte & AcrPdAnnot.GetSubtype & vbCr
                        contents = AcrPdAnnot.GetContents
                        texte = texte & contents & vbCr
                        texte = texte & AcrPdAnnot.GetTitle
                        MsgBox texte
                        'Set AcrPdTSel = AcrPdAnnot.GetRect
                        'Set AcrPdTSel = Nothing
                    Set AcrRect = Nothing
                Set AcrPdAnnot = Nothing
                Set AcrRect = New AcroRect
                    AcrRect.Top = 158
                    AcrRect.Left = 70
                    AcrRect.bottom = 173
                    AcrRect.Right = 107
                    Set AcrPdAnnot = AcrPdP.AddNewAnnot(0, "Link", AcrRect)
                        AcrPdAnnot.SetContents ("")
                    Set AcrPdAnnot = Nothing
                Set AcrRect = Nothing
            Set AcrPdP = Nothing
            AcrApp.SetActiveTool "Hand", 1 'Passe en mode Hand
        Set AcrAvPv = Nothing
    Set AcrAvDoc = Nothing
Set AcrApp = Nothing
End Sub
arnaud_matard est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/10/2007, 13h32   #2
Invité de passage
 
Inscription : novembre 2006
Messages : 23
Détails du profil
Informations forums :
Inscription : novembre 2006
Messages : 23
Points : 4
Points : 4
Par défaut Solution

Bonjour,

Voici la solution.

Cordialement,

Arnaud

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
 
 
Sub crea_link_adobe()
 
Dim AcrApp As Acrobat.AcroApp 'Application Acrobat
Dim AcrAvDoc As Acrobat.AcroAVDoc 'Document actif dans Acrobat
Dim AcrAvPv As Acrobat.AcroAVPageView 'Page active dans Acrobat
Dim AcrPdDoc As Acrobat.AcroPDDoc 'Structure du document actif dans Acrobat
Dim jso As Object 'Modèle javascript du document
Dim popuprect(3) As Integer 'Tableau associé au rectangle du lien
Dim lnk As Object 'Lien
Dim colorinfo(3) As Variant 'Couleur du rectangle associé au lien
 
Set AcrApp = New Acrobat.AcroApp
    AcrApp.SetActiveTool "Link", 1 'Passe en mode Link
    Set AcrAvDoc = AcrApp.GetActiveDoc
        Set AcrAvPv = AcrAvDoc.GetAVPageView
            AcrAvPv.Goto 0 'Va en page 1
        Set AcrAvPv = Nothing
        Set AcrPdDoc = AcrAvDoc.GetPDDoc
            Set jso = AcrPdDoc.GetJSObject
                popuprect(1) = 838 - 158
                popuprect(0) = 70
                popuprect(3) = 838 - 173
                popuprect(2) = 107
                Set lnk = jso.AddLink(0, popuprect)
                    'colorinfo(1) = "RGB"
                    'colorinfo(0) = 1
                    'colorinfo(1) = 0
                    'colorinfo(2) = 0
                    'lnk.BorderColor = colorinfo
                    lnk.BorderWidth = 1
                    lnk.setAction ("this.pageNum = 2")
                Set lnk = Nothing
            Set jso = Nothing
        Set AcrPdDoc = Nothing
    Set AcrAvDoc = Nothing
    AcrApp.SetActiveTool "Hand", 1 'Passe en mode Hand
Set AcrApp = Nothing
End Sub
arnaud_matard est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 21h48.


 
 
 
 
Partenaires

Hébergement Web