Is there a way to test for the start screen on Workbook open.
This is from an Add-in.
Or show blank workbook instead.
Untitled.png
Is there a way to test for the start screen on Workbook open.
This is from an Add-in.
Or show blank workbook instead.
Untitled.png
Not certain I fully understand your question.
It is probably about such a moment when you open the Excel application (without opening the file). At that moment, all the add-ins indicated in the list are loaded. Since no workbook has been opened (xls, xlsx, xlsm) probably the event procedure in our add-in assumes that a workbook is already open and reports an error.
Just check how many workbooks are open:Unless it is about something else. This is just my guess.![]()
If Application.Workbooks.Count = 0 Then
Artik
Oh, very helpful
Thanks Artik, this is what I was referring to.
I've tested by unchecking "Show the Start screen when this application starts" in Excel Options, General.
But still get a count of 0, so the workbook open event seems to be running before the worksheet is shown.
Attachment 796758![]()
Private Sub Workbook_Open() If Application.Workbooks.Count = 0 Then MsgBox "Nil" If Application.Workbooks.Count > 0 Then MsgBox "Open" End Sub
Attachment 796759
Once again.
When opening Excel, the add-ins are loaded first and then the workbook(s). That is, in the Open procedure in the add-in, you will always get result = 0, because the event occurred even before any workbook was opened.
I suggest, describe exactly the problem you have and what you want to achieve, because perhaps checking "Show the Start screen..." is not the right way.
To check whether the "Show the Start screen..." checkbox is checked, you need to look at the system registry with code.
By the way.
Attach attachments to the forum as described in the yellow banner at the top of the page. Other attachment methods may be unreliable.
Artik
Hi Artik, this is a better description.
So if the Show the Start screen box is checked, there is an error message.
If Excel opens like it used to before in a blank worksheet, then no issues.
ThisWorkbook:
module:![]()
Option Explicit Private WithEvents App As Application Private Sub Workbook_Open() Set App = Application End Sub Private Sub App_WorkbookOpen(ByVal Wb As Workbook) Application.Run "initial_stuff" End Sub
![]()
Option Explicit Public when_to_run As Double Public Const interval_sec = 0 'Seconds Public Const what_to_run = "InitialTasks" Private Sub initial_stuff() when_to_run = Now + TimeSerial(0, 0, interval_sec) Application.OnTime EarliestTime:=when_to_run, Procedure:=what_to_run, Schedule:=True End Sub Private Sub InitialTasks() If Does_Worksheet_Exist("Sheet1") Then MsgBox "Exists" End If End Sub Function Does_Worksheet_Exist(WorksheetName As String) As Boolean Dim current_sheet As Worksheet For Each current_sheet In Worksheets If current_sheet.Name = WorksheetName Then Does_Worksheet_Exist = True Exit Function End If Next Does_Worksheet_Exist = False End Function
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks