Getting File Path Too Long Error But It Can't Be Accurate
Results 1 to 8 of 8

Thread: Getting File Path Too Long Error But It Can't Be Accurate
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Jul 2019
    Posts
    3
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

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

    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
        ThisWorkbook.SaveAs standardFile
        
    'Delete slicers and save mobile version to sharepoint
        ThisWorkbook.SaveAs mobileFile
        Call DeleteSlicers
        ThisWorkbook.Save
            
    End Sub

  2. #2
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    26,819
    Post Thanks / Like
    Mentioned
    458 Post(s)
    Tagged
    45 Thread(s)

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

    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?
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

  3. #3
    New Member
    Join Date
    Jul 2019
    Posts
    3
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

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

    Quote Originally Posted by Fluff View Post
    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.

  4. #4
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    26,819
    Post Thanks / Like
    Mentioned
    458 Post(s)
    Tagged
    45 Thread(s)

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

    Is that from the user who is having problems?
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

  5. #5
    Board Regular Norie's Avatar
    Join Date
    Apr 2004
    Location
    Stirling, Scotland
    Posts
    75,121
    Post Thanks / Like
    Mentioned
    60 Post(s)
    Tagged
    6 Thread(s)

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

    What's the full UNC path?

    Are you using SharePoint/OneDrive?
    If posting code please use code tags.

  6. #6
    New Member
    Join Date
    Jul 2019
    Posts
    3
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

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

    Quote Originally Posted by Fluff View Post
    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/per...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


    Quote Originally Posted by Norie View Post
    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/Share...tion/Standard/

    2. \\Company.sharepoint.com@SSL\DavWWWRoot\Shared Documents\Products\Product\Distribution\Production\Files for Distribution\Standard

  7. #7
    Board Regular Norie's Avatar
    Join Date
    Apr 2004
    Location
    Stirling, Scotland
    Posts
    75,121
    Post Thanks / Like
    Mentioned
    60 Post(s)
    Tagged
    6 Thread(s)

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

    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.
    If posting code please use code tags.

  8. #8
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    26,819
    Post Thanks / Like
    Mentioned
    458 Post(s)
    Tagged
    45 Thread(s)

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

    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?
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •