I have some code that automatically generates a filename with today's date from a template file. The code works great IFF excel is completely closed. If any workbooks are open, the code simply does not run.
Here's a sample of my code:
Why does this happen? What can I do to force this macro to run regardless of what workbooks are open?
Thanks,
Nate Unterseher
Here's a sample of my code:
Code:
Option ExplicitPrivate Sub Workbook_Open()
AddDate
filename_cellvalue
OpenPtNames
End Sub
Sub AddDate()
Range("A1").Select
ActiveCell.Value = Date
Range("A3").Select
End Sub
Sub filename_cellvalue()
Dim Path As String
Dim filename As String
Path = "C:\Users\nunterseher.JCC\Desktop\"
filename = Range("d1").Value & ".xlsx"
ActiveWorkbook.SaveAs Path & filename, xlOpenXMLWorkbook
End Sub
Sub OpenPtNames()
Workbooks.Open filename:="C:\Users\nunterseher.JCC\Documents\ZZ Daily other clinics\Clifty Patient Names.xlsx"
ActiveWindow.WindowState = xlMinimized
End Sub
Why does this happen? What can I do to force this macro to run regardless of what workbooks are open?
Thanks,
Nate Unterseher