Bonjour,
Merci pour l'éclairage je comprends mieux cependant là je suis un peu perdu car maintenant le code bloque ici :
Set PDDoc = CreateObject("AcroExch.PDDoc")
Pouvez-vous m'aider à le faire fonctionner svp, s'il fonctionne car sa marche pour ouvrir la pièce jointe en pdf OK, 2-/ mais après il bloque je ne comprends pas pourquoi ??
Voici ma pièce jointe et le code qq peut-il m'aider à l'adapter à mon cas.
Je souhaite ouvrir la pièce jointe récupérer les informations simplement sous fichier excel.
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| 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 Rep 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
Dim shTest As Worksheet
FName = sFichier
Set PDDoc = CreateObject("AcroExch.PDDoc")
Rep = 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)
'wkText = wkText & vbTab & PDText.GetText(j)
Next j
Next i
PDDoc.Close
Set PDPage = Nothing
Set PDText = Nothing
Set oDO = New MSForms.DataObject
oDO.Clear
oDO.SetText wkText
oDO.PutInClipboard
Application.ScreenUpdating = False
Set shTest = Worksheets("Feuil1")
shTest.Cells.Clear
shTest.Range("A1").PasteSpecial
Set oDO = Nothing
Set TextSelt = Nothing
Set PDDoc = Nothing
shTest.Range("Z1").Select
Application.ScreenUpdating = True
End Sub |
Partager