There is nothing wrong with the structure of the code.
I tested it on my system like this:
VBA Code:
Sub MyTest()
Workbooks.Add
Set wbk_syst = ActiveWorkbook
ActiveWorkbook.SaveAs "C:\Temp\system " & Format(Date, "yyyy-mm-dd") & ".xlsx"
Workbooks.Add
Set wbk_doc = ActiveWorkbook
ActiveWorkbook.SaveAs "C:\Temp\documents " & Format(Date, "yyyy-mm-dd") & ".xlsx"
Workbooks.Add
Set wbk_doc = ActiveWorkbook
ActiveWorkbook.SaveAs "C:\Temp\optimization " & Format(Date, "yyyy-mm-dd") & ".xlsx"
End Sub
and I ran it, and it created all three files, like this:
View attachment 64495
The two most likely causes of issues are:
1. You are not setting up the file path and name the way you think, and are actually trying to reference folders that do not exist.
2. You do not have access to save to the folders you are trying to save to.
I would recommend building the file paths/names as variables, and use a MsgBox to return each one to make sure that you are actually created the path/file name that you think you are:
VBA Code:
Workbooks.Add
Set wbk_syst = ActiveWorkbook
fname1 = "\\yExtract\system " & Format(Date, "yyyy-mm-dd") & ".xlsx"
MsgBox fname1
ActiveWorkbook.SaveAs fname1
Workbooks.Add
Set wbk_doc = ActiveWorkbook
fname2 = "\\yExtract\documents " & Format(Date, "yyyy-mm-dd") & ".xlsx"
MsgBox fname2
ActiveWorkbook.SaveAs fname2
Workbooks.Add
Set wbk_opt = ActiveWorkbook
fname3 = "\\yExtract\optimization " & Format(Date, "yyyy-mm-dd") & ".xlsx"
MsgBox fname3
ActiveWorkbook.SaveAs fname3