Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
685 views
in Technique[技术] by (71.8m points)

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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Solution is a OneDrive Setting.

Unchecking "Use Office applications to sunc 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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...