Excel run time error '75' Path/file access error

Smurphster16

New Member
Joined
Feb 28, 2019
Messages
25
Hi All

I have the following code but when it gets to the rename execution statement it fails with the error 75 'path/file access error - I am not sure why as i do have access to read write in the specified location and I am able to rename files in the specified location without using vba.

Is anyone able to help me where I am going wrong with this?

Thanks,

VBA Code:
Sub Rename_Files()

Dim objFileSystem As Object

Set objFileSystem = CreateObject("Scripting.FileSystemObject")
  
Last_CID = Sheets("Full_CID_DB").Range("B" & Rows.Count).End(xlUp).Row
Archive_Location = Sheets("Tables").Range("Archive_Path").Value
Set CID_range = Sheets("Full_CID_DB").Range("B2:B" & Last_CID)

For Each CID In CID_range

Set LEID = CID.Offset(0, 15)

'Path for old file and renamed file
OldFileName = Archive_Location & CID
NewFileName = Archive_Location & LEID
 
'Check if renamed folder already exist
If objFileSystem.FolderExists(NewFolderName) = False Then
 
'Rename the original folder
Name OldFolderName As NewFolderName
'MsgBox "Target Folder is renamed"
 
Else
'MsgBox "Target Folder already exists with same name"

End If


On Error Resume Next


Next
MsgBox ("Folder renaming complete")
End Sub
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
You have Newfilename and NewFoldername as well as oldfilename and oldfoldername…. seems like they should be the same variable name. HTH. Dave
 
Upvote 0
You are also checking to see if the folder exists, not if the file exists.
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,917
Members
449,093
Latest member
dbomb1414

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