Before asking a question I reviewed many options and nothing helped me!
I have in PERSONAL.XLSB
some code. This VBA Saves and closes all books after clicking on the red cross. It works without any problems:
Private WithEvents xlApp As Application
Private Sub Workbook_Open()
Set xlApp = Application
End Sub
Private Sub xlApp_WorkbookBeforeClose(ByVal Wb As Workbook, Cancel As Boolean)
xlApp.ScreenUpdating = False
xlApp.DisplayAlerts = False
xlApp.EnableEvents = False
For Each Wb In xlApp.Workbooks
Wb.Save 'Wb.Close True
Next
xlApp.Quit
End Sub
I have another code which I want to work, when I open the Excel. Separately, this code works, but I do not know how to combine? This code opens my own tab on Ribbon:
Private Sub Workbook_Open()
SendKeys "%BP{F6}", True
End Sub
Want to work when I open any Workbook.