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
|
Option Explicit
' com.adobe.acrobat.accesstext txt
' com.adobe.acrobat.doc doc
' com.adobe.acrobat.eps eps
' com.adobe.acrobat.html-3-20 html, htm
' com.adobe.acrobat.html-4-01-css-1-00 html, htm
' com.adobe.acrobat.jp2k jpf, jpx, jp2, j2k, j2c, jpc
' com.adobe.acrobat.jpeg jpeg, jpg, jpe
' com.adobe.acrobat.plain-text txt
' com.adobe.acrobat.png png
' com.adobe.acrobat.ps ps
' com.adobe.acrobat.RTF rft
' com.adobe.acrobat.tiff tiff, tif
' com.adobe.acrobat.xml-1-00 xml
Sub SelectionFichier()
Dim FD As FileDialog
Set FD = Application.FileDialog(msoFileDialogFilePicker)
With FD
.InitialFileName = ThisWorkbook.Path
.AllowMultiSelect = False
.Filters.Clear
.Filters.Add "PDF", "*.pdf", 1
.ButtonName = "Ouvrir fichier"
.Title = "Sélectionner un fichier PDF"
End With
If FD.Show = True Then Lire FD.SelectedItems(1)
Set FD = Nothing
End Sub
Private Sub Lire(sFichier As String)
Dim AcroXApp As Object
Dim AcroXAVDoc As Object
Dim AcroXPDDoc As Object
Dim JSO As Object
Dim sCheminPDF As String, sChemin As String
Set AcroXApp = CreateObject("AcroExch.App")
AcroXApp.Hide
sCheminPDF = sFichier
sChemin = ThisWorkbook.Path & "\" & "Essai.txt"
Set AcroXAVDoc = CreateObject("AcroExch.AVDoc")
AcroXAVDoc.Open sCheminPDF, "Acrobat"
AcroXAVDoc.BringToFront
Set AcroXPDDoc = AcroXAVDoc.GetPDDoc
Set JSO = AcroXPDDoc.GetJSObject
JSO.SaveAs sChemin, "com.adobe.acrobat.accesstext"
AcroXAVDoc.Close False
AcroXApp.Exit
Set JSO = Nothing
Set AcroXPDDoc = Nothing
Set AcroXAVDoc = Nothing
Set AcroXApp = Nothing
End Sub |
Partager