Exporter un relevé bancaire PDF en EXCEL

  • Initiateur de la discussion Initiateur de la discussion friseb
  • Date de début Date de début

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

friseb

XLDnaute Occasionnel
Bonjour,


Le site de ma banque ne me permet pas d'obtenir mon relevé bancaire sous forme excel. Je ne peux l'avoir que sous forme PDF.

Pour des raisons de comptabilité, je voudrais l'obtenir sous forme excel. Comment puis je faire pour l exporter sur excel.


merci
 
Re : Exporter un relevé bancaire PDF en EXCEL

Re, cette macro enregistre le fichier PDF sélectionné au format Texte
Fonctionne sur mon PC, affecter un bouton à SelectionFichier

Sur mon PC AcrobatReader 9.4.3 et Acrobat Distiller Pro 6.0.4
Il te reste à écrire la macro de lecture avec traitement éventuel du fichier texte généré ou dans le meilleur des cas à l'importer directement sous Excel ou via le menu Données/Données Externes
Code:
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"
    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

    Set AcroXAVDoc = CreateObject("AcroExch.AVDoc")
    AcroXAVDoc.Open sCheminPDF, "Acrobat"

    AcroXAVDoc.BringToFront

    Set AcroXPDDoc = AcroXAVDoc.GetPDDoc
    Set JSO = AcroXPDDoc.GetJSObject

    sChemin = ThisWorkbook.Path & "\" & "Essai.txt"
    
    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

Le fichier de Bruno ,du lien donné plus haut ,légèrement modifié
Code:
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 R1 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")
    R1 = 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 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

A essayer, remplacer
Code:
wkText = wkText & PDText.GetText(j)
par
Code:
wkText = wkText & vbTab & PDText.GetText(j)

Sinon il y a Google avec des convertisseurs en ligne : conserve le colonnage d'un tableau ,ce qui n'est pas le cas des 2 solutions proposées.
 
Dernière édition:
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

Réponses
1
Affichages
109
Réponses
25
Affichages
1 K
Retour