Sub DoRename()
Name "c:\test.xls" As "c:\test2.xls"
End Sub
Another way of doing it is by using the CreateObject function:
Sub DoRename()
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
fso.MoveFile "c:\test.xls", "c:\test2.xls"
Set fso = Nothing
End SubDim fso As Object
Set fso = CreateObject("Scripting.FileSystemOb
fso.MoveFile "c:\test.xls", "c:\test2.xls"
Set fso = Nothing
Another function of this two routines is that it can be used to move a file from folder to another. Here are examples:
Sub DoMove()
Name "c:\folder1\test.xls" As "c:\folder2\test.xls"
End Sub
Moving a file using CreateObject function:
Sub DoRename()
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
fso.MoveFile "c:\folder1\test.xls", "c:\folder2\test.xls"
Set fso = Nothing
End SubDim fso As Object
Set fso = CreateObject("Scripting.FileSystemOb
fso.MoveFile "c:\folder1\test.xls", "c:\folder2\test.xls"
Set fso = Nothing
Your blog is like an encyclopedia for those who want to know more about this. Thanks for the interesting information.
ReplyDelete