ThisWorkbook.Path value running Office/365 and onedrive

ask2tsp

Well-known Member
Joined
Feb 18, 2015
Messages
506
Office Version
  1. 365
Platform
  1. Windows
T
o create files in the folder where the workbook is located
Thisworkbook.Path is the preferred choice, but that gives errors with Office/365 and onedrive.
In my case Thisworkbook.Path=

"https://d.docs.live.net/beccd3471f9cbf60/Documenten/code snippets/Symbol table"

local (in my laptop) this is

"D:\OneDrive\Documenten\code snippets\Symbol table"

Code:
replace(mid(Thisworkbook.Path,instr(Thisworkbook.Path,split(Thisworkbook.Path,"/")(4))),"/","\")
results in

"Documenten\code snippets\Symbol table"

Now prepend "D:\OneDrive" (everything in this folder is synced with onedrive)
and I get a path I can use with fso.OpenTextFile

Is this "D:\OneDrive" value retrievable somewhere?
And to make this work with different exel versions (2013 and later) how to code that?
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,223,967
Messages
6,175,664
Members
452,666
Latest member
AllexDee

We've detected that you are using an adblocker.

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.
Go back
Back
Top