I have this code that I've been working with this morning. As it is now, when I run it the Workbook is saved in a folder corresponding to the current year. Works great, however if a Workbook has already been saved the same day it will save over the top of the previous file. I'm trying to add a hh:mm:ss timestamp to the code so additional saves don't replace previous files.
Here's my code:
I tried this without success:
I'm getting this error:
Here's my code:
VBA Code:
Sub SaveWorkbook()
Dim rootDirectory As String
Dim folderToBeCreated As String
Dim path As String
rootDirectory = "\\GLC-SERVER\Pulte\Z_Pulte Master Archive\"
folderToBeCreated = Format(Now, "yyyy")
path = rootDirectory & folderToBeCreated
If Len(Dir(rootDirectory, vbDirectory)) <> 0 Then
If Len(Dir(path, vbDirectory)) = 0 Then
VBA.MkDir (path)
Else
End If
Else
End If
ChDrive "Z"
ChDir "\\GLC-SERVER\Pulte\Z_Pulte Master Archive\"
ActiveWorkbook.SaveAs FileName:="\\GLC-SERVER\Pulte\Z_Pulte Master Archive\" & year(Date) & "\" & "Pulte Master " & Format(Now, "yyyymmdd") & ".xlsm", FileFormat:=52
End Sub
I tried this without success:
VBA Code:
ActiveWorkbook.SaveAs FileName:="\\GLC-SERVER\Pulte\Z_Pulte Master Archive\" & year(Date) & "\" & "Pulte Master " & Format(Now, "yyyymmdd hh:mm:ss") & ".xlsm", FileFormat:=52
I'm getting this error: