VBA 'MkDir' causing run time error for new PC user

RJSIGKITS

Board Regular
Joined
Apr 15, 2013
Messages
109
Hi Guys.
So, I have a new user for the main PC (Logging in with own PC login details), and the Doc that I need all users on the PC to be able to use has the below lines of code that is currently causing a 'Run Time Error 76 - Path not found' error message for debugging. However, I have compared the FilePath etc, and nothing is different from the ... Why will this cause an error for the new user, but not for the main user?
Code:
Private Sub BtnSave_Click()Dim Path As String
Dim FileName1 As String
Path = "D:\Data\Docs\Tonido\1. *******s\2 CLIENTS"
FileName1 = Range("I2")
If Dir(Path & "\" & FileName1, vbDirectory) = "" Then
    MkDir (Path & "\" & FileName1)
The filepath on the new users login is:
'D:\Data\Docs\Tonido\1. *******s\2 CLIENTS'
I can't understand why this would run an error?
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Does the new user have access to that path?
 
Upvote 0
I think I understand what you're saying, but I am sure all the levels are the same as the primary user?..
I have this as my full code:
Code:
Private Sub BtnSave_Click()Dim Path As String
Dim FileName1 As String
Path = "D:\Data\Docs\Tonido\1. *******s\2 CLIENTS"
FileName1 = Range("I2")
If Dir(Path & "\" & FileName1, vbDirectory) = "" Then
    MkDir (Path & "\" & FileName1)
    MkDir (Path & "\" & FileName1 & "\V1")
    MkDir (Path & "\" & FileName1 & "\Photos")
    MkDir (Path & "\" & FileName1 & "\Photos" & "\Before")
    MkDir (Path & "\" & FileName1 & "\Photos" & "\Progress")
    MkDir (Path & "\" & FileName1 & "\Photos" & "\After")
    MkDir (Path & "\" & FileName1 & "\Order")
    MkDir (Path & "\" & FileName1 & "\Order" & "\SO")
    MkDir (Path & "\" & FileName1 & "\Order" & "\SO" & "\Remedials")
    MsgBox "Success!" & vbCr & "A New Client Record has been created successfully", vbExclamation + vbOKOnly, "Success!"
    Sheets("Client").Unprotect Password:="Password"
    
    Sheets("Client").Protect Password:="Password"
    ThisWorkbook.Sheets("Home").Activate
    Else
     If MsgBox("A Record Already Exists for this Client" & vbCr & "Click OK to save changes to this record", vbExclamation + vbOKOnly, "Error") = vbOK Then
     ThisWorkbook.Save
    ThisWorkbook.Sheets("Home").Activate
    Exit Sub
    End If
End If
ActiveWorkbook.SaveAs Filename:=Path & "\" & FileName1 & "\" & FileName1 & ".xlsm", FileFormat:=52
End Sub
Debugging highlights "MkDir (Path & "" & FileName1)"
 
Upvote 0
What does:

Code:
Dir(Path, vbDirectory)

return for that user?
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

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