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

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,215,054
Messages
6,122,895
Members
449,097
Latest member
dbomb1414

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