JeffKotnik
New Member
- Joined
- Jun 7, 2013
- Messages
- 4
Folks, I am posting for the first time here and please forgive me if I don't do it exactly right.
I am working on a VBA program that will import CSV files to Excel using Power Query. I am quite familiar with VBA but have never used Power Query.
So I recorded a macro to get the code. It works perfectly.
But the problem is, since I recorded the macro, the file location and name are absolute references (Source = Csv.Document(File.Contents(""C:\aaaTest\test 01.csv"")). I need to replace these with variables. But the code as written won't accept a variable. How would I structure this code so as to be able use variables?
I appreciate any help, including just clues, that will point me in the right direction.
Thanks,
Jeff
I am working on a VBA program that will import CSV files to Excel using Power Query. I am quite familiar with VBA but have never used Power Query.
So I recorded a macro to get the code. It works perfectly.
But the problem is, since I recorded the macro, the file location and name are absolute references (Source = Csv.Document(File.Contents(""C:\aaaTest\test 01.csv"")). I need to replace these with variables. But the code as written won't accept a variable. How would I structure this code so as to be able use variables?
VBA Code:
wbControl.Queries.Add Name:="Query1", Formula:= _
"let" & Chr(13) & "" & Chr(10) & " Source = Csv.Document(File.Contents(""C:\aaaTest\test 01.csv""), [Delimiter=""="", Columns=1, Encoding=1252, QuoteStyle=QuoteStyle.None])," & Chr(13) & "" & Chr(10) & " #""Changed Type"" = Table.TransformColumnTypes(Source,{{""Column1"", type text}})" & Chr(13) & "" & Chr(10) & "in" & Chr(13) & "" & Chr(10) & " #""Changed Type"""
I appreciate any help, including just clues, that will point me in the right direction.
Thanks,
Jeff