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
| Option Explicit
Sub SelFichier()
Dim Fichier As Variant
Dim sMot As String
ChDir ThisWorkbook.Path
' Mot à rechercher
sMot = "Investments"
Fichier = Application.GetOpenFilename("Fichier PDF (*.pdf), *.pdf")
If Fichier <> False Then AcrobatFindText Fichier, sMot
End Sub
Private Sub AcrobatFindText(ByVal sFichier As String, ByVal sRch As String)
Dim oApp As Object
Dim oAvDoc As Object
Dim iTrouvé As Integer
Set oApp = CreateObject("AcroExch.App")
oApp.Hide
Set oAvDoc = CreateObject("AcroExch.AVDoc")
If oAvDoc.Open(sFichier, "") Then
If Len(sRch) > 0 Then
' Parametres FindText
' StringToSearchFor ,
' caseSensitive (1 Or 0),
' WholeWords(1 Or 0),
' ResetSearchToBeginOfDocument (1 Or 0)
' Rencoie -1 si Trouvé, 0 autrement
iTrouvé = oAvDoc.FindText(sRch, True, False, True)
Else
oAvDoc.Close (1)
Set oAvDoc = Nothing
Set oApp = Nothing
Exit Sub
End If
End If
oApp.Show
oAvDoc.BringToFront
Set oAvDoc = Nothing
Set oApp = Nothing
End Sub |
Partager