D
DavidH56
Hi,
Could someone please assist me with obtaining the correct code for renaming
a file or multiple files in a directory to include its creation date. This is
the code I have so far and thanks in advance for any assistance:
Sub RenameFileToDatedFile()
'Install a refernce to library: Microsoft Scripting Runtime
Dim FSO As New FileSystemObject
Dim afile As file 'Handle for fso 'File' Object
Dim aPath As String
Dim aName As String
Dim sNewFile As String
Dim sOldFile As String
'Set up your filespec
aPath = sfol = "C:\Temp\Reports\"
aName = "pcb.ppt"
If FSO.FileExists(aPath & aName) Then
Set afile = FSO.GetFile(aPath & aName) '<< Example of setting
handle
' MsgBox "The File exists " & aFile.DateCreated
'Range("B50") = aFile.DateCreated
sOldFile = "C:\Temp\Reports\pcb.ppt"
sNewFile = "C:\Temp\Reports\Final PCB Data " & Format(afile.DateCreated,
"dd-mmm-yy") & ".ppt"
Name sOldFile As sNewFile
End If
'Clean House
Set afile = Nothing
End Sub
Could someone please assist me with obtaining the correct code for renaming
a file or multiple files in a directory to include its creation date. This is
the code I have so far and thanks in advance for any assistance:
Sub RenameFileToDatedFile()
'Install a refernce to library: Microsoft Scripting Runtime
Dim FSO As New FileSystemObject
Dim afile As file 'Handle for fso 'File' Object
Dim aPath As String
Dim aName As String
Dim sNewFile As String
Dim sOldFile As String
'Set up your filespec
aPath = sfol = "C:\Temp\Reports\"
aName = "pcb.ppt"
If FSO.FileExists(aPath & aName) Then
Set afile = FSO.GetFile(aPath & aName) '<< Example of setting
handle
' MsgBox "The File exists " & aFile.DateCreated
'Range("B50") = aFile.DateCreated
sOldFile = "C:\Temp\Reports\pcb.ppt"
sNewFile = "C:\Temp\Reports\Final PCB Data " & Format(afile.DateCreated,
"dd-mmm-yy") & ".ppt"
Name sOldFile As sNewFile
End If
'Clean House
Set afile = Nothing
End Sub