Importer PDF en excel avec VBA
lucieaup
Messages postés
17
Date d'inscription
Statut
Membre
Dernière intervention
-
cs_Le Pivert Messages postés 7904 Date d'inscription Statut Contributeur Dernière intervention -
cs_Le Pivert Messages postés 7904 Date d'inscription Statut Contributeur Dernière intervention -
Bonjour,
je cherche à créer un mini outil pour importer des PDF sous fichier Excel. Aujourd'hui je recois des centaines de PDF par semaine des officiels un peu partout en europe et je dois les charger manuellement un à un dans notre ERP (SAP). j'ai un moyen de les rentrer en masse mais il faut que ca vienne d'un ficheir excel.
Je ne peux pas utiliser un convertisseur en ligne car nous ne sommes pas administrateurs de nos machines et que j'ai affaire à 12 pays en europe, tous n'ont pas les même accés, c'est pourquoi je veux le coder moi même en VBA.
J'ai trouvé ce code en fouinant sur le WEB mais ca ne marche pas sur mon fichier..
'In order to use the macro you must enable the Acrobat library from VBA editor:
'Go to Tools -> References -> Adobe Acrobat xx.0 Type Library, where xx depends
'on your Acrobat Professional version (i.e. 9.0 or 10.0) you have installed to your PC.
'Alternatively you can find it Tools -> References -> Browse and check for the path
'C:\Program Files\Adobe\Acrobat xx.0\Acrobat\acrobat.tlb
'where xx is your Acrobat version (i.e. 9.0 or 10.0 etc.).
Dim PDFApp As AcroApp
Dim PDFDoc As AcroAVDoc
Dim PDFPageView As AcroAvPageView
Dim PDFPath As String
Dim DisplayPage As Integer
'Change this to your own complete PDF path
'Full path example
'PDFPath = "C:\Program Files\Autodesk\ACADM 2010\Setup\en-US\SetupRes\Docs\Acad_Mech_2010_UserGuide.pdf"
'For Word
'PDFPath = ThisDocument.Path & "\" & "PDF Sample.pdf"
'For Power Point
'PDFPath = ActivePresentation.Path & "\" & "PDF Sample.pdf"
'For Excel
PDFPath = ThisWorkbook.Path & "\" & "PDF Sample.pdf"
'Set the page you want to be displayed
DisplayPage = 3
'Initialize Acrobat by creating App object
Set PDFApp = CreateObject("AcroExch.App")
'Set AVDoc object
Set PDFDoc = CreateObject("AcroExch.AVDoc")
'Open the PDF
If PDFDoc.Open(PDFPath, "") = True Then
PDFDoc.BringToFront
'Maximize the document
Call PDFDoc.Maximize(True)
Set PDFPageView = PDFDoc.GetAVPageView()
'Go to the desired page
'The first page is 0
Call PDFPageView.GoTo(DisplayPage - 1)
'-------------
'ZOOM options
'-------------
'0 = AVZoomNoVary
'1 = AVZoomFitPage
'2 = AVZoomFitWidth
'3 = AVZoomFitHeight
'4 = AVZoomFitVisibleWidth
'5 = AVZoomPreferred
'Set the page view of the pdf
Call PDFPageView.ZoomTo(2, 50)
End If
Set PDFApp = Nothing
Set PDFDoc = Nothing
On Error Resume Next
'Show the adobe application
PDFApp.Show
'Set the focus to adobe acrobat pro
AppActivate "Adobe Acrobat Pro"
End Sub
Est ce que quelqu'un pourrait m'aider ?
Merci
je cherche à créer un mini outil pour importer des PDF sous fichier Excel. Aujourd'hui je recois des centaines de PDF par semaine des officiels un peu partout en europe et je dois les charger manuellement un à un dans notre ERP (SAP). j'ai un moyen de les rentrer en masse mais il faut que ca vienne d'un ficheir excel.
Je ne peux pas utiliser un convertisseur en ligne car nous ne sommes pas administrateurs de nos machines et que j'ai affaire à 12 pays en europe, tous n'ont pas les même accés, c'est pourquoi je veux le coder moi même en VBA.
J'ai trouvé ce code en fouinant sur le WEB mais ca ne marche pas sur mon fichier..
'In order to use the macro you must enable the Acrobat library from VBA editor:
'Go to Tools -> References -> Adobe Acrobat xx.0 Type Library, where xx depends
'on your Acrobat Professional version (i.e. 9.0 or 10.0) you have installed to your PC.
'Alternatively you can find it Tools -> References -> Browse and check for the path
'C:\Program Files\Adobe\Acrobat xx.0\Acrobat\acrobat.tlb
'where xx is your Acrobat version (i.e. 9.0 or 10.0 etc.).
Dim PDFApp As AcroApp
Dim PDFDoc As AcroAVDoc
Dim PDFPageView As AcroAvPageView
Dim PDFPath As String
Dim DisplayPage As Integer
'Change this to your own complete PDF path
'Full path example
'PDFPath = "C:\Program Files\Autodesk\ACADM 2010\Setup\en-US\SetupRes\Docs\Acad_Mech_2010_UserGuide.pdf"
'For Word
'PDFPath = ThisDocument.Path & "\" & "PDF Sample.pdf"
'For Power Point
'PDFPath = ActivePresentation.Path & "\" & "PDF Sample.pdf"
'For Excel
PDFPath = ThisWorkbook.Path & "\" & "PDF Sample.pdf"
'Set the page you want to be displayed
DisplayPage = 3
'Initialize Acrobat by creating App object
Set PDFApp = CreateObject("AcroExch.App")
'Set AVDoc object
Set PDFDoc = CreateObject("AcroExch.AVDoc")
'Open the PDF
If PDFDoc.Open(PDFPath, "") = True Then
PDFDoc.BringToFront
'Maximize the document
Call PDFDoc.Maximize(True)
Set PDFPageView = PDFDoc.GetAVPageView()
'Go to the desired page
'The first page is 0
Call PDFPageView.GoTo(DisplayPage - 1)
'-------------
'ZOOM options
'-------------
'0 = AVZoomNoVary
'1 = AVZoomFitPage
'2 = AVZoomFitWidth
'3 = AVZoomFitHeight
'4 = AVZoomFitVisibleWidth
'5 = AVZoomPreferred
'Set the page view of the pdf
Call PDFPageView.ZoomTo(2, 50)
End If
Set PDFApp = Nothing
Set PDFDoc = Nothing
On Error Resume Next
'Show the adobe application
PDFApp.Show
'Set the focus to adobe acrobat pro
AppActivate "Adobe Acrobat Pro"
End Sub
Est ce que quelqu'un pourrait m'aider ?
Merci
A voir également:
- Pdf to excel vba
- Lire le coran en français pdf - Télécharger - Histoire & Religion
- Liste déroulante excel - Guide
- Word et excel gratuit - Guide
- Save as pdf office 2007 - Télécharger - Bureautique
- Qwerty to azerty - Guide
2 réponses
Bonjour,
voir ceci:
https://groups.google.com/forum/?fromgroups#!topic/excelvbamacros/hPZsy2QyFGM
Pour que cela fonctionne il faut mettre cette partie dans un module à part et ensuite suivre les indications pour changer le chemin de l'exe :
' change the path of adobe program as per your desktop
task = Shell("C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe "
voir ceci:
https://groups.google.com/forum/?fromgroups#!topic/excelvbamacros/hPZsy2QyFGM
Pour que cela fonctionne il faut mettre cette partie dans un module à part et ensuite suivre les indications pour changer le chemin de l'exe :
' change the path of adobe program as per your desktop
task = Shell("C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe "
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) _ As Long Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess _ As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long Public Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As _ Long, ByVal uExitCode As Long) As Long Public Const SYNCHRONIZE = &H100000 Public Const STANDARD_RIGHTS_REQUIRED = &HF0000
https://www.cjoint.com/c/HDfqmIgJSLQ
mais comme le dit Patrice33740, il s'agit d'un copier coller. Voir si cela convient!
@+
Merci beaucoup mais ca ne marche pas, je ne comprends pas pourquoi. Qaund je cherche adobe dans mon PC je ne trouve que le raccourci est-ce pour ca?
Voila le type de fichier que je veux mettre sur excel
https://www.cjoint.com/c/HDgis1FnWm6
Merci