Renaming Non-Excel Files
Sub MoveFile()
Dim fso
Dim file As String, sfol As String, dfol As String, destFile
file = "Test.txt" ' change to match the file name
destFile = "TestMe.txt"
sfol = "C:\" ' change to match the source folder path
dfol = "C:\" ' change to match the destination folder path
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FileExists(sfol & file) Then
MsgBox sfol & file & " does not exist!", vbExclamation, "Source
File Missing"
ElseIf Not fso.FileExists(dfol & file) Then
fso.MoveFile (sfol & file), dfol & destFile
Else
MsgBox dfol & file & " already exists!", vbExclamation,
"Destination File Exists"
End If
End Sub
HTH
Die_Another_Day
QTGlennM wrote:
I am trying to figure out if I can rename non-excel files with excel.
I have a sheet with my file names in column A
G:\New Folder\Blank DA 1594.FPK
G:\New Folder\DA 1594 Example.pdf
and in column B I have the new names that I want to change them to.
G:\New Folder\Blank DA 1594 27 July 06.FPK
G:\New Folder\DA 1594 27 July 06.pdf
If anyone can help I would greatly appreciate it!!!!
Thanks in advance.
Glenn
|