I am simply shocked that I have not been able to find a simple solution to this. Excel and OneDrive are both Microsoft products so you would think they would work better together.
I am looking for a simple way to get the path of the VBA file (activeworkbook) and use it to open another file in the same folder. The problem is when the file is stored and synced in a onedrive folder.
METHODS I HAVE TRIED:
METHOD 1
I tried CurDir, but this has a tendency to not be correct. I dont really understand what this is supposed to be retrieving because it is not the current directory of the active file. It seems to use the directory of the last location that was selected from within Excel. So if i open my file from within excel, then I am good to go until i open another file location from within excel, then the CurDir will be that location until the next one, and so on.
METHOD 2
Similar results with this most recent method i tried. i was thinking i finally found something that seemed to work, but later realized that it seemed to be behaving the same as CurDirMETHOD 3![]()
Please Login or Register to view this content.
I recently considered using the following to stop/start onedrive during the process, but not knowing the system of any given user, i thought it best to not use this method.METHOD 4![]()
Please Login or Register to view this content.
I also looked for a way to swap the path from OneDrive sharepoint path to local synced path. so if ThisWorkbook.Path is a URL, then replace the "https://[sharepoint]/personal/[user]/Documents/" with the users local path of their onedrive, like C:\Users\[user]\[OneDrive]\ (and of course swap the remaining "/" to "\") but i have not been successful in figuring this method out.
Does anyone here know of a way that will easily accomplish what i am trying to do?
I have come across some posts that claim to do this for varying purposes, but they all have been very long code that I cant follow so I wouldnt know how to adapt to my needs.
Hoping someone has a simple creative solution to this.
Bookmarks