SOLVED

UserName in saved path of excel macro

Copper Contributor

Hi All. I have a macro that creates a PDF from the spreadsheet. I save this to a central onedrive folder. On my own PC, this is "C:\Users\Bill\OneDrive - Folder two\PDF's". I want all my users to be able to use this macro. So far I have been changing the name of each user individually. Is there a way I can make it for the default user? I did try "C:\Users\%UserName%\OneDrive - Folder two\PDF's" but this did not work. TIA.

2 Replies
best response confirmed by BillZab (Copper Contributor)
Solution

@BillZab 

Try

 

Environ("HomeDrive") & Environ("HomePath") & "\OneDrive - Folder two\PDF's"

 

(Do all users really have a folder named OneDrive - Folder two?)

Thanks again Hans, this worked.

The Folder name is not as I used in my example. It is a company shared folder.
1 best response

Accepted Solutions
best response confirmed by BillZab (Copper Contributor)
Solution

@BillZab 

Try

 

Environ("HomeDrive") & Environ("HomePath") & "\OneDrive - Folder two\PDF's"

 

(Do all users really have a folder named OneDrive - Folder two?)

View solution in original post