Search code examples
excelvbaonedrive

Excel VBA Get Physical Location, not OneDrive URL


I'm used VBA in excel to create some simple files, that should be saved in the same location as the excel file.

I get the location of the excel file with this:

ActiveWorkbook.Path

The problem is that this always returns the OneDrive URL, like this:

https://d.docs.live.net/641ebe6d8******/Work/Projects.......

What I'm looking for is the physical location on my hard drive.

I've tried closing OneDrive application on my computer, and opening the file from the directory itself, but still the location from above gives me a OneDrive URL.

Any ideas how to get the directory path on my harddrive instead?


Solution

  • Solution is a OneDrive Setting.

    Unchecking "Use Office applications to sync Office files that I open" makes it use the local directory. This effect is true even when OneDrive app is closed on my computer.

    Uncheck this box