mysticmario
Active Member
- Joined
- Nov 10, 2021
- Messages
- 323
- Office Version
- 365
- Platform
- Windows
Hi I run into this issue with Application on time the code below runs perfectly fine. It selects one of the sheets, copy it to new file, saves it an d closes the file it created:
But when I want to add Application.ontime I get a windows error:
that Macro WorkbookSave cannot be run either beacase this sheet doesnt allow macros or all macros are turned off.
Here's the code:
Can anyone help with that?
VBA Code:
Private Sub Workbook_Open()
Application.DisplayAlerts = False
Sheets("MAIN").Select
Sheets("Aktualnie zalogowani").Select
Sheets("Aktualnie zalogowani").Copy
ChDir "C:\Users\Shelby\Documents\Listy obecności"
ActiveWorkbook.SaveAs Filename:= _
("C:\Users\Shelby\Documents\Listy obecności\Lista obecności" & Format(Now(), "DD-MMM-YYYY") & ".xlsx"), FileFormat:= _
xlOpenXMLWorkbook, CreateBackup:=False
ActiveWindow.Close savechanges = False
Sheets("MAIN").Select
Application.DisplayAlerts = True
End Sub
But when I want to add Application.ontime I get a windows error:
that Macro WorkbookSave cannot be run either beacase this sheet doesnt allow macros or all macros are turned off.
Here's the code:
Code:
Private Sub Workbook_Open()
Application.DisplayAlerts = False
Sheets("MAIN").Select
Sheets("Aktualnie zalogowani").Select
Sheets("Aktualnie zalogowani").Copy
ChDir "C:\Users\Shelby\Documents\Listy obecności"
ActiveWorkbook.SaveAs Filename:= _
("C:\Users\Shelby\Documents\Listy obecności\Lista obecności" & Format(Now(), "DD-MMM-YYYY") & ".xlsx"), FileFormat:= _
xlOpenXMLWorkbook, CreateBackup:=False
ActiveWindow.Close savechanges = False
Sheets("MAIN").Select
Application.DisplayAlerts = True
Application.OnTime TimeValue("11:05:00"), "WorkbookSave"
End Sub
Sub WorkbookSave()
Application.DisplayAlerts = False
Sheets("MAIN").Select
Sheets("Aktualnie zalogowani").Select
Sheets("Aktualnie zalogowani").Copy
ChDir "C:\Users\Shelby\Documents\Listy obecności"
ActiveWorkbook.SaveAs Filename:= _
("C:\Users\Shelby\Documents\Listy obecności\Lista obecności" & Format(Now(), "DD-MMM-YYYY") & ".xlsx"), FileFormat:= _
xlOpenXMLWorkbook, CreateBackup:=False
ActiveWindow.Close savechanges = False
Sheets("MAIN").Select
Application.DisplayAlerts = True
End Sub
Can anyone help with that?