-
TESSST
Sub VBAAdvancedRenameFile()
'Create variables to hold file names
Dim filePath As String
Dim newFilePath As String
filePath = "C:\Users\marks\Documents\Example File.xlsx"
newFilePath = "C:\Users\marks\Documents\Example File Renamed.xlsx"
'Ignore errors
On Error Resume Next
'Rename file
Name filePath As newFilePath
'Display message if error occured
If Err.Number <> 0 Then
MsgBox Prompt:="Unable to rename file", Buttons:=vbOK, _
Title:="Rename file error"
End If
'Turn error checking back on
On Error GoTo 0
End Sub
Sorry, there were no replies found.
Log in to reply.