Override for 218 character limit for filename & path when saving through VBA

James Talvy
James Talvy used Ask the Experts™
on
I have a macro that publishes a PDF file and saves it to a shared directory. The filepath is quite long and I often run into the situation where the filename and path exceed the 218 character limit set in Excel. Is there a workaround for this? I am unable to use relative paths since this will be used by multiple users that may have the drives mapped differently.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016

Commented:
Hi,

It doesn't seem possible
https://support.microsoft.com/en-us/kb/213983

Regards

Commented:
Change the file naming policy, I do not see many other solutions
JohnBusiness Consultant (Owner)
Most Valuable Expert 2012
Expert of the Year 2018

Commented:
DON'T.  Shorten the filenames, else you be back saying something else does not work. Filenames that are too long is a universally bad idea.
IT Consultant
Commented:
it is always a good practice to define a relatively short, still meaningful convention for naming long filenames and folder names.

however, as a spare solution you may consider using SHORTENED version of filenames, the traditional 8.3 naming convention, instead of the long version in your VBA code.

foe example, use C:\PROGRA~1\ instead of C:\Program Files\, this may significantly reduce the string length for accessing a pathname.

FYI -

How to Find 8.3 Filenames
http://superuser.com/questions/348079/how-can-i-find-the-short-path-of-a-windows-directory-file

How Windows Generates 8.3 Filenamea from Long Filenames
https://support.microsoft.com/en-us/kb/142982

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial