Daten aus PDF in Excel-Mappe
16.07.2020 14:45:24
Marc
ich muss aus den Pdf-Dateien, die in einem Ordner liegen Daten in die Excel-Mappe übertragen. nachdem ich was im Netz gefunden und mit meiner Schleife angepasst habe, dachte ich es funktioniert, das tat es nicht. Er öffnet die Datein, die existieren nicht. Er lädt nicht mal das "file = Shell()".
Könnt ihr mal mrüber schauen und mir helfen🙈
Private Sub laden()
Dim fileStr As String
Dim file As Variant
Dim pdf As String
Dim d As Date
Dim a As Long
Dim x As Long
Set appWord = CreateObject("Word.Application")
fileStr = "C:\Beispiel\"
d = Format(Now, "DD.MM.YYYY")
For x = 1 To 7
For d = d - 7 + x To d
For i = 0 To 3
pdf = "Beispieldatei_" & d & "_" & i & ".pdf"
file = Shell(fileStr & "\" & pdf, vbNormalFocus)
If Dir(fileStr & "\" & pdf, vbNormal) "" Then
Application.Wait (Now + TimeSerial(0, 0, 2))
SendKeys ("^a")
SendKeys ("^c")
SendKeys "%{F4}"
Application.Wait Now + TimeValue("00:00:01")
Set appWord = CreateObject("Word.Application")
appWord.Visible = False
appWord.Documents.Add.Content.Paste
With appWord
.Selection.WholeStory
.Selection.Copy
.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
.Quit
End With
Set ws1 = ThisWorkbook.Worksheets(1)
With ws1
a = .Range(.Cells(1, 1), .Cells(.Cells(Rows.Count, 1).End(xlUp).Row)).Count
.Cells(a + 1, 1).Select
.Paste
End With
Else
End If
Next i
Next d
Next x
End Sub
Gruß Marc