Microsoft 365 Extraire des champs particuliers d'un PDF dans Excel

sj4555

XLDnaute Junior
Bonjour à tous,

J'ai actuellement une macro me permettant de copier l'intégralité contenu d'un PDF sur mon classeur Excel, et le problème c'est que je n'ai aucune idée de comment affiner cette Macro pour qu'elle ne prenne que certains champs du fichier PDF,

Exemple: sur mon fichier PDF il y a un champs "date :" avec la date à côté, comment procéder pour copier uniquement le champs date avec EN PLUS la date se trouvant à côté

Voici ma macro :

VB:
Sub test()
Dim CheminEtTypeFichier As String, Fichier As String
Dim sFichier As String
Dim sAcro As String
 
    With Feuil1
        .Activate
        .Cells.Clear
    End With
 
'Variable à définir : Le chemin par défaut
CheminEtTypeFichier = "C:\Users"
 
Fichier = BrowseFile(CheminEtTypeFichier)
 
    If Fichier <> "" Then
        'MsgBox "Nom du fichier sélectionné : """
        sFichier = Split(Fichier, "")(UBound(Split(Fichier, "")))
        sAcro = "C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe"
 
        Shell sAcro, vbNormalFocus
 
        Application.Wait (Now + TimeValue("0:00:02"))
        SendKeys "^o"
        Application.Wait (Now + TimeValue("0:00:02"))
        SendKeys sFichier
        Application.Wait (Now + TimeValue("0:00:02"))
        SendKeys "{ENTER}"
        Application.Wait (Now + TimeValue("0:00:02"))
 
        SendKeys "^a"
        Application.Wait (Now + TimeValue("0:00:02"))
        SendKeys "^c"
        Application.Wait (Now + TimeValue("0:00:02"))
        SendKeys "^q"
        Application.Wait (Now + TimeValue("0:00:02"))
 
        DoEvents
        With Feuil1
            .Range("A1").Select
            .Activate
            .Paste
        End With
    Else
        MsgBox "Aucune sélection a été effectuée."
    End If
End Sub
 
Function BrowseFile(CheminEtTypeFichier) As String
    With Application.FileDialog(msoFileDialogFilePicker)
        'Définit un titre pour la boîte de dialogue
        .Title = "Choisir le fichier"
        'Empêcher la multi-sélection
        .AllowMultiSelect = False
        'Répertoire par défaut suivi du type de fichier par défaut
        .InitialFileName = CheminEtTypeFichier
        'Efface les filtres existants.
        .Filters.Clear
        'Indique le type d'affichage dans la boîte de dialogue
        '(exemple visualisation des propriétés)
        .InitialView = msoFileDialogViewProperties
        'Affiche la boîte de dialogue
        .Show
        If .SelectedItems.Count > 0 Then
            BrowseFile = .SelectedItems(1)
        Else
            BrowseFile = ""
        End If
    End With
End Function

Merci
 

kiki29

XLDnaute Barbatruc

Pièces jointes

  • Pdf2Txt_05_Fichiers.jpg
    Pdf2Txt_05_Fichiers.jpg
    221.8 KB · Affichages: 124
  • Pdf2Txt_Clipboard_05.jpg
    Pdf2Txt_Clipboard_05.jpg
    349.8 KB · Affichages: 108
Dernière édition:

Discussions similaires

Statistiques des forums

Discussions
311 720
Messages
2 081 915
Membres
101 837
dernier inscrit
Ugo