When I use ThisWorkbook.path I get back a URL (https://...) instead of a file path (C:\...). How do I use VBA to get the local file path? For context, the workbook I'm using is saved in my OneDrive folder.
Ok... so I moved the workbook out of my OneDrive folder and ThisWorkbook.path functions correctly. Why is it that it doesn't work when the file is in the OneDrive folder? Does anyone know of a Sub that gets the local path of a workbook in the OneDrive folder?
Once you are on the webpage either search for his name and scroll up or search for his opening line which is: "In case your OneDrive folder is not in default location, the code below will allow you to locate the file wherever it is."
I don't currently have access to Sharepoint but I think it might work for that too.
This works for me. I have three OneDrives (2 for different employers and a personal one), so I need to identify the name of the OneDrive folder. I think you could use something like this if you only have a single OneDrive:
VBA Code:
Environ$("OneDrive") & "\Folder\Subfolder\etc.\"
Alternatively, you can turn off automatic syncing while running the macro, which should allow ThisWorkbook.Path to function normally.
We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel
Which adblocker are you using?
Disable AdBlock
Follow these easy steps to disable AdBlock
1)Click on the icon in the browser’s toolbar. 2)Click on the icon in the browser’s toolbar. 2)Click on the "Pause on this site" option.
Go back
Disable AdBlock Plus
Follow these easy steps to disable AdBlock Plus
1)Click on the icon in the browser’s toolbar. 2)Click on the toggle to disable it for "mrexcel.com".
Go back
Disable uBlock Origin
Follow these easy steps to disable uBlock Origin
1)Click on the icon in the browser’s toolbar. 2)Click on the "Power" button. 3)Click on the "Refresh" button.
Go back
Disable uBlock
Follow these easy steps to disable uBlock
1)Click on the icon in the browser’s toolbar. 2)Click on the "Power" button. 3)Click on the "Refresh" button.