Forum Discussion

BillZab's avatar
BillZab
Copper Contributor
Feb 20, 2023
Solved

UserName in saved path of excel macro

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.

  • BillZab 

    Try

     

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

     

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

2 Replies

  • BillZab 

    Try

     

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

     

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

    • BillZab's avatar
      BillZab
      Copper Contributor
      Thanks again Hans, this worked.

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

Resources