I have a PDF that has three pages - each page has a header and detail and the last page has an additional footer.
I'd like to use Power Query to import the PDF tables into Excel
I ran the File ->Get data ->From File -> From PDF and it came back with 6 tables and three pages
I'd like to import the First table as my header, then tables 2, 4 and 6 as the detail and 6 will also have the footer.
I recorded a macro when I did this and it came back with the following code (PDF_Path substituted for hard path) for Table001
When I run this code from a button push event, it give me an error - "System Error & H80070057 (-2147024809). The Parameter is incorrect". I'm not sure what the issue is, it was generated from the system.
I'd like to use Power Query to import the PDF tables into Excel
I ran the File ->Get data ->From File -> From PDF and it came back with 6 tables and three pages
I'd like to import the First table as my header, then tables 2, 4 and 6 as the detail and 6 will also have the footer.
I recorded a macro when I did this and it came back with the following code (PDF_Path substituted for hard path) for Table001
VBA Code:
Sub PDF_PQ(PDF_Path As String)
ActiveWorkbook.Queries.Add Name:="Table001 (Page 1)", Formula:= _
"let" & Chr(13) & "" & Chr(10) & " Source = Pdf.Tables(File.Contents(""" & PDF_Path & """), [Implementation=""1.3""])," & Chr(13) & "" & Chr(10) & " Table001 = Source{[Id=""Table001""]}[Data]," & Chr(13) & "" & Chr(10) & " #""Changed Type"" = Table.TransformColumnTypes(Table001,{{""Column1"", type text}, {""Column2"", type text}})" & Chr(13) & "" & Chr(10) & "in" & _
"" & Chr(13) & "" & Chr(10) & " #""Changed Type"""
ActiveWorkbook.Worksheets.Add
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _
"OLEDB;Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=""Table001 (Page 1)"";Extended Properties=""""" _
, Destination:=Range("$A$1")).QueryTable
.CommandType = xlCmdSql
.CommandText = Array("SELECT * FROM [Table001 (Page 1)]")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.ListObject.DisplayName = "Table001__Page_1"
.Refresh BackgroundQuery:=False
End With
End Sub
When I run this code from a button push event, it give me an error - "System Error & H80070057 (-2147024809). The Parameter is incorrect". I'm not sure what the issue is, it was generated from the system.