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
 

Some videos you may like

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
42,832
Office Version
365
Platform
Windows
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?
 

AppleGaming

New Member
Joined
Jul 1, 2019
Messages
3
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.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
42,832
Office Version
365
Platform
Windows
Is that from the user who is having problems?
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,660
Office Version
365
Platform
Windows
What's the full UNC path?

Are you using SharePoint/OneDrive?
 

AppleGaming

New Member
Joined
Jul 1, 2019
Messages
3
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
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,660
Office Version
365
Platform
Windows
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.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
42,832
Office Version
365
Platform
Windows
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?
 

Watch MrExcel Video

Forum statistics

Threads
1,102,633
Messages
5,488,017
Members
407,617
Latest member
Samanthad2007

This Week's Hot Topics

  • Timer in VBA - Stop, Start, Pause and Reset
    [CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
  • how to updates multiple rows in muliselect listbox
    Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
  • Delete Row from Table
    I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
  • Assigning to a variable
    I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
  • Way to verify information
    Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
  • Active Cell Address – Inactive Sheet
    How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...
Top