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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
| ' ajout de la référence Acrobat (My Project -> onglet Référence -> click ajouter -> onglet COM -> sélection Acrobat)
Imports Acrobat
Public Class Form1
Public Client As String = "MaDifferenceAMoi" 'me permet de différencier un pdf que j'ai ouvert avec l'appli d'un autre portant le meme nom
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim DocPdf As String = "Test.pdf"
Dim DocumentPDF As String = Application.StartupPath & "\" & DocPdf
Dim avApp As AcroApp
Dim avDoc As AcroAVDoc
avApp = CreateObject("AcroExch.App")
avDoc = CreateObject("AcroExch.AVDoc")
avDoc.Open(DocumentPDF, Client & " - " & DocPdf)
avApp.Show()
avApp.Exit()
avApp = Nothing
avDoc = Nothing
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim DocPdf As String = "Test2.pdf"
Dim DocumentPDF As String = Application.StartupPath & "\" & DocPdf
Dim avApp As AcroApp
Dim avDoc As AcroAVDoc
avApp = CreateObject("AcroExch.App")
avDoc = CreateObject("AcroExch.AVDoc")
avDoc.Open(DocumentPDF, Client & " - " & DocPdf)
avApp.Show()
avApp.Exit()
avApp = Nothing
avDoc = Nothing
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim DocPdf As String = "Test.pdf"
Dim DocumentPDF As String = Application.StartupPath & "\" & DocPdf
Dim avApp As Acrobat.AcroApp
Dim avDoc As Acrobat.AcroAVDoc
avApp = CreateObject("AcroExch.App")
avDoc = CreateObject("AcroExch.AVDoc")
Dim nb As Integer
Dim nDoc As Integer
If avApp.GetNumAVDocs > 0 Then
For nDoc = avApp.GetNumAVDocs - 1 To 0 Step -1
avDoc = avApp.GetAVDoc(nDoc)
nb = Len(Client & " - " & DocPdf)
If Mid(avDoc.GetTitle, 1, nb) = Client & " - " & DocPdf Then
avDoc.Close(2)
End If
Next
End If
If avApp.GetNumAVDocs = 0 Then
avApp.CloseAllDocs()
avApp.Hide()
End If
avApp.Exit()
avApp = Nothing
avDoc = Nothing
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Dim DocPdf As String = "Test2.pdf"
Dim DocumentPDF As String = Application.StartupPath & "\" & DocPdf
Dim avApp As Acrobat.AcroApp
Dim avDoc As Acrobat.AcroAVDoc
avApp = CreateObject("AcroExch.App")
avDoc = CreateObject("AcroExch.AVDoc")
Dim nb As Integer
Dim nDoc As Integer
If avApp.GetNumAVDocs > 0 Then
For nDoc = avApp.GetNumAVDocs - 1 To 0 Step -1
avDoc = avApp.GetAVDoc(nDoc)
nb = Len(Client & " - " & DocPdf)
If Mid(avDoc.GetTitle, 1, nb) = Client & " - " & DocPdf Then
avDoc.Close(2)
End If
Next
End If
If avApp.GetNumAVDocs = 0 Then
avApp.CloseAllDocs()
avApp.Hide()
End If
avApp.Exit()
avApp = Nothing
avDoc = Nothing
End Sub
End Class |