Excel VBA - Path to CSV file in Power Query

tjdrake

New Member
Joined
Aug 2, 2022
Messages
19
Office Version
  1. 2021
Platform
  1. Windows
Greetings & Salutations!

I'm working on completing an Excel app for my users. The user will download a file from a web app in CSV format. By default, the program is set to pickup the file from the C:\\Users\xxxx\downloads folder. Within the Excel folder there is a named range that holds the variable

VBA Code:
let Range("DownloadLocation")= "C:\Users\" & Environ$("UserName") & "\Downloads"

getDownloadLocation function
Power Query:
let
    Source = () => let
        Source = Excel.CurrentWorkbook(){[Name="DownloadLocation"]}[Content],
        MyList=Table.ToList(Source){0}
    in
       MyList
in
    Source

Subsequently, the PowerQuery executes the function, and when I invoke the function, it works great too . Interestingly, while it works wonderfully for my laptop, it is seemingly hanging-up on my remote test user's laptop.

ComplianceView dataset
Power Query:
let
    Source = Csv.Document(File.Contents(getDownloadLocation() &  "Compliance_View.csv"),[Delimiter=",", Columns=29, Encoding=65001, QuoteStyle=QuoteStyle.None]),
    #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Super Region", type text}, {"Region", type text}, {"Warehouse", type text}, {"Employee ID", Int64.Type}, {"Employee Login", type text}, {"Employee Name", type text}, {"job_level", Int64.Type}, {"Shift", type text}, {"Hire Date", type datetime}, {"Day 1", type datetime}, {"Manager Login", type text}, {"Receive", type text}, {"Stow", type text}, {"Smart Stow", type text}, {"ADTA Mini", type text}, {"Pick & Stage", type text}, {"Pick to Buffer", type text}, {"Induct", type text}, {"Divert", type text}, {"Induct Pusher", type text}, {"Induct Loader", type text}, {"Dock Associate", type text}, {"Waterspider", type text}, {"Problem Solve", type text}, {"ASL Aligner", type text}, {"ASL Line Loader", type text}, {"ADTA Stower", type text}, {"ADTA Straightener", type text}, {"Fully ASL Trained", type text}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"Super Region", "Region"}),
    #"Sorted Rows" = Table.Sort(#"Removed Columns",{{"Employee ID", Order.Ascending}}),
    #"Filtered Rows" = Table.SelectRows(#"Sorted Rows", each ([Warehouse] = get_DSID()))
in
    #"Filtered Rows"

Thoughts or suggestions on what is causing this?

I've looked through a couple similar threads, most 400+ days old w/o a solid resolution. Perhaps someone has a solve or found a thread that I missed.

Thank you,
tjd
 
Last edited by a moderator:

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Forum statistics

Threads
1,224,818
Messages
6,181,151
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top