Run-time Error 52, Bad file name or number

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • adanvilla10
    New Member
    • May 2019
    • 1

    Run-time Error 52, Bad file name or number

    Problem with Excel Macro contacting a SharePoint folder in Windows 10.
    I have a model that has been running under Windows 7 for several years without a problem. When i migrated to Windows 10 the part of the macro that is looking for a folder on SharePoint no longer works. I have tried the same macro but referencing a local file on my laptop and there is no problem.
    When I ran the debug it highlights the line for:

    If Len (Dir(vSource & vFile) ) = 0 Then


    [IMGnothumb]https://bytes.com/attachment.php? attachmentid=10 019[/IMGnothumb]
    Attached Files
    Last edited by zmbd; May 26 '19, 12:48 AM. Reason: [z{inserted image inline with post, fixed a typo :) }]
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    Your replaced your system (from Windows7 to Windows 10), you did not change anything to the macro in Excel, and it gives an error.

    Option 1: You have not enough right (under windows 10) to access this SharePoint folder.

    Option 2: Something is missing to your installation of Excel under Windows 10.

    For this to solve more info is needed than a picture and the description you gave in the subject of this message.

    What values do the variables 'vSource' and 'vFile' have? Do they point to a correct destination in SharePoint?

    When reading Error 52 on the site of Microsoft, its unclear if this is related to your problem.

    Comment

    • zmbd
      Recognized Expert Moderator Expert
      • Mar 2012
      • 5501

      #3
      Luuk, your link points to the system level error
      This is the link to
      VBA Runtime Error 52

      What values do the variables 'vSource' and 'vFile' have? Do they point to a correct destination in SharePoint?
      Exactly, this is your first trouble shooting step.
      Place a few Debug.print and <ctrl><g> to see how these two strings are resolving.

      Comment

      • Luuk
        Recognized Expert Top Contributor
        • Mar 2012
        • 1043

        #4
        @zmdb: I was 'as-lazy-as' @adanvilla10,
        and did stop reading after 'Error 52'

        The text after this 'Bad file name or number' would (or should) have made bells ringing.

        @adanvilla10: Happy debugging!

        Comment

        • zmbd
          Recognized Expert Moderator Expert
          • Mar 2012
          • 5501

          #5
          mea-culpa : We stand among great friends : Happens even to the best of us, look back thru my posts thru the years (how did that happen?!), Neopa, Rabbit, and I think even you have fixed many of my oversights :)

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32633

            #6
            That's some code with a lot of problems. Forget the logic. It's a mess.

            Check out Before Posting (VBA or SQL) Code. Oh, and always post the code in text as a picture is as close to useless as you ever want to get.

            PS. Well done Zmbd, but don't sweat it Luuk. As Z says - we all make mistakes from time to time.

            Comment

            Working...