Bonjour à tous,
j'aimerai exporter les donées d'un PDF sur excel en VBA à l'aide d'un bouton à cliquer
j'utilise un MAC avec adobe acrobat pro avec licence
j'utilise ce code de
@kiki29
mais il me dit toujours "Erreur d'execution 91" variable objet ou bloc with non définie
quelq'un peut m'aider svp?
Option Explicit
Sub SelectionFichier2()
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 Lire2 FD.SelectedItems(1)
Set FD = Nothing
End Sub
' Cocher Reference : Microsoft Forms 2.0 Object Library
Sub Lire2(sFichier As String)
Dim PDDoc As Object
Dim PDPage As Object
Dim PDText As Object
Dim TextSelt As Object
Dim Rep As Long
Dim i As Long, j As Long
Dim wkPage As Long
Dim wkCnt As Long
Dim wkText As String
Dim FName As String
Dim oDO As Object
FName = sFichier
Set PDDoc = CreateObject("AcroExch.PDDoc")
Rep = PDDoc.Open(FName)
Set TextSelt = CreateObject("AcroExCh.HiliteList")
TextSelt.Add 0, 32767
wkPage = PDDoc.GetNumPages()
For i = 0 To wkPage - 1
Set PDPage = PDDoc.AcquirePage(i)
Set PDText = PDPage.CreatePageHilite(TextSelt)
wkCnt = PDText.GetNumText()
For j = 0 To wkCnt - 1
wkText = wkText & PDText.GetText(j)
Next j
Next i
PDDoc.Close
Set PDPage = Nothing
Set PDText = Nothing
Set oDO = New MSForms.DataObject
oDO.Clear
oDO.SetText wkText
oDO.PutInClipboard
Application.ScreenUpdating = False
ShTest.Cells.Clear
ShTest.Range("A1").PasteSpecial
Set oDO = Nothing
Set TextSelt = Nothing
Set PDDoc = Nothing
ShTest.Range("H1").Select
Application.ScreenUpdating = True
End Sub