How to change old Environ file path to work with one drive

MZING81

Board Regular
Joined
Mar 20, 2012
Messages
75
I had a number of workbooks that other co-workers use.
I have have vba code:

Workbooks.Open filename:=(Environ(“userprofile”) &

how do I convert that to work with One drive?
Unfortunately my dept. received no warning on this update from our higher ups so it’s reeking havoc with running van code.

many help is greatly appreciated!
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Map a drive to One Drive, to see with your IT …​
 
Upvote 0
Hi,

if you mean open files on local OneDrive folders on different PCs you need the User name folder in the path

C:\Users\<Username>\OneDrive\Documents\

Code:
Usr = Environ("UserName")

Workbooks.Open "C:\Users\" & Usr & "\OneDrive\Documents\Test.txt"
 
Upvote 0

Forum statistics

Threads
1,225,749
Messages
6,186,802
Members
453,373
Latest member
Ereha

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