Here's file path my code:
I want the archived file path to look like this: \\GLC-SERVER\Pulte\Z_Pulte Master Archive\2022\Pulte Master 20220415.xlsm
Unfortunately what I'm getting is this: \\GLC-SERVER\Pulte\Pulte Master 20220415.xlsm
Here's the whole macro:
What am I missing?
VBA Code:
ChDir "\\GLC-SERVER\Pulte\Z_Pulte Master Archive\" & year(Date) & "\"
ActiveWorkbook.SaveCopyAs FileName:="Pulte Master " & Format(Now, "yyyymmdd") & ".xlsm"
I want the archived file path to look like this: \\GLC-SERVER\Pulte\Z_Pulte Master Archive\2022\Pulte Master 20220415.xlsm
Unfortunately what I'm getting is this: \\GLC-SERVER\Pulte\Pulte Master 20220415.xlsm
Here's the whole macro:
VBA Code:
Sub SaveWorkbook()
Application.EnableEvents = False
Application.ScreenUpdating = False
Application.DisplayAlerts = False
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\" & year(Date) & "\"
ActiveWorkbook.SaveCopyAs FileName:="Pulte Master " & Format(Now, "yyyymmdd") & ".xlsm"
Application.EnableEvents = True
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
What am I missing?
Last edited: