Copy excel file to default user temp folder.

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
Hi, can vba make out user's temp path and copy file from E:\Personal_Files\myvba.xlsm to window's temp folder and then open the file?

Thanks and regards
Pedie
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
The user's TEMP folder is Environ("TEMP"), so this would copy the file to the TEMP folder:-
Code:
[FONT=Courier New]FileCopy "E:\Personal_Files\myvba.xlsm", Environ("temp") & "\myvba.xlsm"[/FONT]
Then I suppose you'd just do:-
Code:
[FONT=Courier New]Workbooks.Open Environ("temp") & "\myvba.xlsm"[/FONT]
Before doing the FileCopy I would probably delete the file from TEMP if it's already there:-
Code:
[FONT=Courier New]If Dir(Environ("temp") & "\myvba.xlsm") <> "" Then [/FONT][FONT=Courier New]Kill [/FONT][FONT=Courier New]Environ("temp") & "\myvba.xlsm"[/FONT]
And I'd probably Kill it once I'd finished using it.

But then I'm a Virgo.
 
Upvote 0
Ruddles, exactly what I wanted..
Thank you for sharing the code.

Regards
Pedie
 
Upvote 0
1-4552411-9245-t.jpg
 
Upvote 0

Forum statistics

Threads
1,224,606
Messages
6,179,862
Members
452,948
Latest member
UsmanAli786

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