Run-time 52 Bad file name or number error on one network system

Viewed 1572

I am receiving the Run-time error '52' bad file name or number error, however all of the questions which cover this on stackoverflow that I can see have answers which involve changing the code. The problem with this is that the code uses a directory in a network drive, and the error doesn't occur on other computers on the network.

It is perhaps worth noting that my computer until recently did not have an activated version of windows due to a complication, however I assumed that to be the cause of the error but it is still occurring after activation.

I have no experience with Microsoft Visual Basic and did not write the code so if you need any more information just ask.

Private Sub Command1769_Click()
Me.Refresh

If Len(Dir("file location" & 
[Combo1199], vbDirectory)) = 0 Then
MkDir "file location" & 
[Combo1199]
End If

I have replaced the name of the file location with 'file location' however I have checked and it is correct. The [Combo1199] is the name of a folder which is already present in the directory, and its date modified shows as being when the VBA code was run. The debug shows the problem as occurring on the If Len(... line

EDIT SOLVED: For some reason the DNS servers weren't set to be found automatically so I wasn't connected to the applicable license server.

1 Answers

Amongst other possible reasons, in my experience, run-time error 52 can arise when a path is valid but inaccessible, for example, a mapped network drive for which the user has insufficient read permissions, or which cannot be accessed due to the target being offline.

I would therefore suggest that you print the path represented by "file location" & [Combo1199] to the Immediate Window (view this using Ctrl+G in the VBA IDE) using:

Debug.Print "file location" & [Combo1199]

And then ensure that you can access this location 'manually' through File Explorer from the same PC, using the same user credentials that are active when the code runs.

Related