Have you tried FSO?
Something like this will rename the file in the same folder.
You can modify it with various options.
Code:
Private Sub sRenameCsv(FPath As String, NewName As String)
Dim fil As Object, FExt As String, PFol As String
'late binding
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
'early binding
'Dim fso As New FileSystemObject
Set fil = fso.GetFile(FPath)
FExt = "." & fso.GetExtensionName(FPath) 'get the file extension
PFol = fso.GetParentFolderName(FPath) 'get the parent folder path
If Not fso.FileExists(fso.BuildPath(PFol, NewName & FExt)) Then 'check that the re-named file does not exist
fso.MoveFile FPath, fso.BuildPath(PFol, NewName & FExt) 'move the file to same folder with new name
Else
MsgBox "File already exists"
End If
Set fso = Nothing
End Sub
If the periods(.) in the directory names are a problem, you can rename and move the file to a different folder
Code:
Private Sub sRenameMoveCsv(FPath As String, NewFolderPath As String, NewName As String)
'FPath - Path to the file to rename
'NewFolderPath - path to the folder to save file to.
'NewName - new file name
Dim fil As Object, FExt As String, PFol As String
'late binding
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
'early binding
'Dim fso As New FileSystemObject
Set fil = fso.GetFile(FPath)
FExt = "." & fso.GetExtensionName(FPath) 'get the file extension
If Not fso.FileExists(fso.BuildPath(NewFolderPath, NewName & FExt)) Then 'check that the re-named file does not exist
fso.MoveFile FPath, fso.BuildPath(NewFolderPath, NewName & FExt) 'move the file to new folder with new name
Else
MsgBox "File already exists"
End If
Set fso = Nothing
End Sub