Feb 29 2024 08:10 AM
Hello,
I have a query that currently imports a pdf file based on a specific file name and location. I'm trying to make the file name and location relative but keep getting an error. I'm using Excel365.
This is the Source line from the hard coded pdf import:
let
Source = Pdf.Tables(File.Contents("C:\Users\User26\Documents\Projects\IG Receivable - Schools\PCR's- Adobe Extension.pdf"), [Implementation="1.3"]),
When I change the code in the advanced editor to the following in order to make it relative I get an stating "DataFormat.Error: External table is not in the expected format"
let
FolderPath = Excel.CurrentWorkbook(){[Name="FolderPath"]}[Content]{0}[Column1],
PCRFileName = Excel.CurrentWorkbook(){[Name="PCRFileName"]}[Content]{0}[Column1],
Source = Excel.Workbook(File.Contents(FolderPath & PCRFileName), null, true),
PCRs = Source(Pdf.Tables(File.Contents((FolderPath & PCRFileName),[Implementation="1.3"])))
in
PCRs
I suspect the issue is with the PCRs = Source line of the code but haven't been able to figure out what. Any suggestions?
Thank you
Bridgett
Mar 01 2024 04:44 AM
SolutionThe first three lines of M-code should look like this:
FolderPath = Excel.CurrentWorkbook(){[Name="FolderPath"]}[Content]{0}[Column1],
PCRFileName = Excel.CurrentWorkbook(){[Name="PCRFileName"]}[Content]{0}[Column1],
Source = Pdf.Tables(File.Contents(FolderPath & PCRFileName), [Implementation="1.3"]),
Now you can navigate to the table(s) you want to extract from the PDF.
Mar 05 2024 08:07 AM
That worked perfectly! Thank you!@Riny_van_Eekelen
Mar 01 2024 04:44 AM
SolutionThe first three lines of M-code should look like this:
FolderPath = Excel.CurrentWorkbook(){[Name="FolderPath"]}[Content]{0}[Column1],
PCRFileName = Excel.CurrentWorkbook(){[Name="PCRFileName"]}[Content]{0}[Column1],
Source = Pdf.Tables(File.Contents(FolderPath & PCRFileName), [Implementation="1.3"]),
Now you can navigate to the table(s) you want to extract from the PDF.