Sub ExtrPdfTxt()
Dim sFichier As String
Dim sAcro As String
Dim keys As String
Dim wsh As Object
Dim T As Single
With Feuil15
.Activate
.Cells.Clear
.Range("A1").Select
End With
sFichier = ThisWorkbook.Path & "\" & "Facture_Alice_201806_20836845_792711202.pdf" 'PDF à extraire
sAcro = "C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe" 'Reader Adobe
Shell sAcro, vbNormalFocus
Tempo 1
Set wsh = CreateObject("WScript.Shell")
wsh.SendKeys "^(o)", False
Tempo 1
wsh.SendKeys sFichier
Tempo 1
wsh.SendKeys "{ENTER}"
Tempo 1
wsh.SendKeys "^a"
Tempo 1
wsh.SendKeys "^c"
Tempo 0.5
wsh.SendKeys "^q"
Tempo 0.5
Set wsh = Nothing
Tempo 1
'DoEvents ' Pas vraiment utile ...
With Feuil15
.Activate
.Paste
.Range("B1").Select
End With
End Sub
Sub Tempo(T)
Dim PauseTime, Start, Finish, TotalTime
If T = "" Then T = 3
PauseTime = T ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop
Finish = Timer ' Set end time.
TotalTime = Finish - Start ' Calculate total time.
End Sub
Partager