[Power Query] Using Windows environment variable to seek for folder

Copper Contributor

I've done office sript for several people for reporting 3D printing. I've managed to make excel to look for latest "*.gcode" file in temp folder and then extract content into table (via power query). And then with office script it does formatting.
The problem is that when other user executes script, the file path in power query is constant. I would like to make it variable as it is in windows (%TEMP%). Typing %TEMP% does not work. 
I'm not not very familiar of power query also office scripts.
I've searched for solution in other posts, but the source file name in each post is constant, mine is not. I cannot change the path for seeking for file, it must be %TEMP%.

Zrzut ekranu 2023-12-12 143327.pngZrzut ekranu 2023-12-12 143409.png

1 Reply

Hi @kna_mekoprint 


Unfortunately you can't get an Environment variable via Power Query. Same goes with Excel functions, VBA is required


I quickly searched but didn't find info. saying this would be doable with Office Script (double-check in case I missed it)


Obviously doable with Power Automate: