Links for filepaths too long (+260) fix?

Alejandro Gombao

New Member
Joined
Dec 21, 2022
Messages
6
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
  5. 2013
  6. 2010
  7. 2007
Platform
  1. Windows
  2. Web
Hello,

I have designed an Index for a repository of documentation in which every cell has a Link to open the corresponding file.

It all works wonderfully until the paths start getting longer, since there are docens of directories and subdirectories deepness.

Is there any way so the link can work even if it's so long?

The error when you click on the link is:
1671645128431.png


I have also noticed that if I rightclick and open the "modify hyperlink", then copy the link to the file and paste it in my file explorer, it works... So I hope there is some way to bypass the error.

Thank you in advance
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Hello,

I have designed an Index for a repository of documentation in which every cell has a Link to open the corresponding file.

It all works wonderfully until the paths start getting longer, since there are docens of directories and subdirectories deepness.

Is there any way so the link can work even if it's so long?

The error when you click on the link is:
View attachment 81347

I have also noticed that if I rightclick and open the "modify hyperlink", then copy the link to the file and paste it in my file explorer, it works... So I hope there is some way to bypass the error.

Thank you in advance
Have you thought of using a URL shortener? Most browsers have an extension that will do this, some against multiple services:
1671719471197.png

That's a Chrome extension simply called Url Shortener, and as illustrated can use several services. The shortened link for this page is https://tinyurl.com/2hwqr7ds
 
Upvote 0
Have you thought of using a URL shortener? Most browsers have an extension that will do this, some against multiple services:
View attachment 81435
That's a Chrome extension simply called Url Shortener, and as illustrated can use several services. The shortened link for this page is https://tinyurl.com/2hwqr7ds
Hello, thanks for your reply.

Maybe it wasn't clear enough, but the "repository of documentation" I'm talking about is a series of servers located in the local network of my company. The links that lead to those files are generated automatically, directly to the excel sheet.

Don't think it would be possible to pass all those links from excel through any link shortener, to be honest...
 
Upvote 0
Hello, thanks for your reply.

Maybe it wasn't clear enough, but the "repository of documentation" I'm talking about is a series of servers located in the local network of my company. The links that lead to those files are generated automatically, directly to the excel sheet.

Don't think it would be possible to pass all those links from excel through any link shortener, to be honest...
You would need to get the LAN technicians to provide an auxiliary shorter drive mapping further down the path. Typically a network drive like F: is mapped to the root of server storage. If all of your files are under F:\Path1\Path2\Path3, a new drive letter could be assigned to that path so to get to the files in Path3 you'd address X:\ thus shortening the path. That mapping could be done for just you and doesn't need to be a global change. In some environments you could execute the command MAP X: F:\Path1\Path2\Path3 from a command prompt, or that command could be added to your personal login script.
Alternatively the folders would need to have their names shortened, but that could cause major problems! Good luck!
 
Upvote 0
You would need to get the LAN technicians to provide an auxiliary shorter drive mapping further down the path. Typically a network drive like F: is mapped to the root of server storage. If all of your files are under F:\Path1\Path2\Path3, a new drive letter could be assigned to that path so to get to the files in Path3 you'd address X:\ thus shortening the path. That mapping could be done for just you and doesn't need to be a global change. In some environments you could execute the command MAP X: F:\Path1\Path2\Path3 from a command prompt, or that command could be added to your personal login script.
Alternatively the folders would need to have their names shortened, but that could cause major problems! Good luck!
Yeaaah I thought about that, and it is indeed already done.
Sadly, after doing that a number of about 3000 files have their lengths on around 420 chars length of full repository deepness... Guess they will have to be copy-pasting the links untill Microsoft decides to make a file explorer that supports LongPaths

Thank you anyway
 
Upvote 0
Yeaaah I thought about that, and it is indeed already done.
Sadly, after doing that a number of about 3000 files have their lengths on around 420 chars length of full repository deepness... Guess they will have to be copy-pasting the links untill Microsoft decides to make a file explorer that supports LongPaths

Thank you anyway
You could always open a Command Prompt window and use the command:
DIR F:\Path1\Path2\Path3\*.xlsx /S /B >FileList.txt
the /S parameter is to scan all subdirectories, and the /B parameter is to show the entire file path and name (Bare).
That will output a text file named FileList with all the files listed with their entire path through all sub directories. There will be no word wrapping in the fille even though it would wrap on the screen if that's where the output went instead of the text file.
 
Upvote 0
Give each part it's own name
VBA Code:
a = C:\A Folder Name Here\Another Folder Name Here\And One More\
aa = Folder_Four\Folder_Five\Folder_Six\
aaa = Folder_Seven\Folder_Eight\Folder_nine\
aaaa = Folder_Ten\Folder_Eleven\Folder_Twelve
Path = a & aa & aaa & aaaa
 
Upvote 0
Give each part it's own name
VBA Code:
a = C:\A Folder Name Here\Another Folder Name Here\And One More\
aa = Folder_Four\Folder_Five\Folder_Six\
aaa = Folder_Seven\Folder_Eight\Folder_nine\
aaaa = Folder_Ten\Folder_Eleven\Folder_Twelve
Path = a & aa & aaa & aaaa
I think you would need each literal string part in double-quotes (Text Qualifier).
And you should NOT use reserved words like "Path" as the name of your variables. Doing so can cause errors and unexpected results.

So your code should be updated like this:
VBA Code:
a = "C:\A Folder Name Here\Another Folder Name Here\And One More\"
aa = "Folder_Four\Folder_Five\Folder_Six\"
aaa = "Folder_Seven\Folder_Eight\Folder_nine\"
aaaa = "Folder_Ten\Folder_Eleven\Folder_Twelve"
MyPath = a & aa & aaa & aaaa
 
Upvote 0
Thanks Joe.
It was only meant as an example and thinking that the OP new that. And if not, he/she would learn something what might be a plus.
If you say all of that, what about mentioning that I did not show to dimension all of these as strings.
Your signature says it all. Give a man a perfect code and he'll be happy for as long as no changes are required. Teach him when falling down to get up up and he'll learn something. (Changed to suit the occasion)
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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