Excel 2016 VBA, Windows 10
I'm trying to use VBA to Get Data. I want to use a relative reference. I just want to get data from 'Raw Keyword.csv' in the same folder as the xlsm file. It never seems to recognize the relative path. I tried building it with all the quotes around it (option A, preferred) and passing that variable to Folder.Files. I saw a suggestion to put the Path and filename in File.Contents in another thread (link below) but that didn't work either. Any suggestions?
' Option A
Dim RawK As String
RawK = """""" & ActiveWorkbook.Path & "\Raw Keyword.csv" & """"""
ActiveWorkbook.Queries.Add Name:="Query Keyword", Formula:= _
"let" & Chr(13) & "" & Chr(10) & " Source = Csv.Document(File.Contents(RawK)...
' Option B:
ActiveWorkbook.Queries.Add Name:="Query Keyword", Formula:= _
"let" & Chr(13) & "" & Chr(10) & " Source = Csv.Document(File.Contents(ActiveWorkbook.Path & ""\Raw Keyword.csv"") ...
Saw a similar answer here, but no luck with that. Relative path for Folder.Files