Getting File Path Too Long Error But It Can't Be Accurate

AppleGaming

New Member
Joined
Jul 1, 2019
Messages
3
I'm getting run-time error '1004': The file path you entere is too long. Enter a shorter file name or select a shorter file path, and then try saving the file again.

When I debug I get taken to "ThisWorkbook.SaveAs StandardFile"

However, I'm only getting this error when a particular user on his computer runs the code. There are two other users that run the code and have no issues. The file length never changes in size just the date. Additionally, this doesnt make sense because I've gone to the trouble to map the sharepoint paths to drives on the local computer. So the path that gets saved is

A:\qwer asdfghjk zxcvbnm 07_02_2019 Mobile and Excel 2007.xlsm

and that is well under the max length. Finally, even if the path was not mapped and I wanted to save directly to the sharepoint, the path is only 233 at it's longest.

Anyone have thoughts? googleing this is near impossible because I dont think the path error is accurate even though that's whats getting reported.

Code:
Private Sub SaveBothVersions(FirstAvailableNetworkDrive As String, SecondAvailableNetworkDrive As String)
    
'Retrieve ActiveWorkbook's File Path (Displayed in Immediate Window [ctrl + g])
    strFileFullName = ThisWorkbook.FullName


'Retrieve File Name with Extension
    nameExtension = Right(strFileFullName, Len(strFileFullName) - InStrRev(strFileFullName, "\"))


'Retrieve File Name without Extension
    nameNoExtension = Mid(strFileFullName, InStrRev(strFileFullName, "\") + 1, InStrRev(strFileFullName, ".") - InStrRev(strFileFullName, "\") - 1)
    
'Create full path to save down
    standardFile = FirstAvailableNetworkDrive & nameExtension
    mobileFile = SecondAvailableNetworkDrive & nameNoExtension & " Mobile and Excel 2007.xlsm"
    
'Save current version
    ThisWorkbook.Save
    
'Save standard file to sharepoint
    [U][B]ThisWorkbook.SaveAs standardFile[/B][/U]
    
'Delete slicers and save mobile version to sharepoint
    ThisWorkbook.SaveAs mobileFile
    Call DeleteSlicers
    ThisWorkbook.Save
        
End Sub
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Hi & welcome to MrExcel.
Add this just before the SaveAs
Code:
MsgBox standardFile & vbLf & Len(standardFile)
Does the path & filename look correct and what does the 2nd line say?
 
Upvote 0
Hi & welcome to MrExcel.
Add this just before the SaveAs
Code:
MsgBox standardFile & vbLf & Len(standardFile)
Does the path & filename look correct and what does the 2nd line say?

Yes the path looks correct, "A:\qwer asdfghjk zxcvbnm 07_02_2019 Mobile and Excel 2007.xlsm"

and the number is 55.
 
Upvote 0
Is that from the user who is having problems?
 
Upvote 0
What's the full UNC path?

Are you using SharePoint/OneDrive?
 
Upvote 0
Is that from the user who is having problems?

No, sorry. I guess that was implied that I run it from their computer.

This is from the user. I've changed our company and the username so the string below may not add to 128 that was displayed from the msg box.

"E:\http://company-my.sharepoint.com/personal/user_name_company_nyc/Documents/Copy of Copy of Product US product07_02_2019.xlsm

128


The E instead of A is an expected change because the macro finds the first available drive on the computer running it. The error this time is something different than path too long


What's the full UNC path?

Are you using SharePoint/OneDrive?

Not sure what the UNC path is but the path I use in the macro is 1 and the location from properties is 2.


1. https://Company.sharepoint.com/Shar...n/Production/Files for Distribution/Standard/

2. \\Company.sharepoint.com@SSL\DavWWWRoot\Shared Documents\Products\Product\Distribution\Production\Files for Distribution\Standard
 
Upvote 0
If A:\ is a mapped drive then the UNC path would look something like this,

\\server\folder\qwer asdfghjk zxcvbnm 07_02_2019 Mobile and Excel 2007.xlsm

and if you are using OneDrive/SharePoint there is a known problem with file/path lengths.

I'm encountering it more often myself since we've moved over to OneDrive/SharePoint.
 
Upvote 0
Whilst I don't have sharepoint, it looks odd that you have both a drive letter & web address
E:\http://c
Do you get this on the computers that work?
 
Upvote 0

Forum statistics

Threads
1,213,561
Messages
6,114,312
Members
448,564
Latest member
ED38

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