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,
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