0

I have an excel spreadsheet that needs to get the current directory of the file. For a worksheet function I use =LEFT(CELL("filename"),FIND("[",CELL("filename"))-1), in VBA I use ActiveWorkbook.Path. The file is on my hard drive in my OneDrive folder so it is synced to the cloud. Sometimes I have no issues (most of the time), but at times the file directory will be the cloud path (htpps://....) and this will not work.

Does anyone know how to always get the local path?

Uncle Bob
  • 36
  • 4
Charlie
  • 21
  • 1
  • 5
  • You could check if the path is a url (starts with http) If your file is in the cloud, I doubt that your provider allows it and even that it makes sense.. – Oscar Jan 16 '18 at 14:36
  • yes, i could check that, but I still need the local directory. – Charlie Jan 16 '18 at 19:01
  • You can convert the cloud path (url) to a local path using [this solution](https://stackoverflow.com/a/73577057/12287457). – GWD Sep 06 '22 at 00:01

1 Answers1

0

The =INFO("Directory") formula might be able to help with this:

enter image description here

I haven't tried it with One Drive, but the formula seems simpler and less likely to error.

Source: https://gridmaster.io/spreadsheet-tips/show-file-path-excel

bryanbraun
  • 3,025
  • 2
  • 26
  • 38