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

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
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,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

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