Search code examples
excelvbaexcel-2016excel-addins

Run code once add-ins have finished loading


I have code under workbook_open procedure. At the beginning of this code a userform (loading screen) initiates whilst the remainder of the code runs to hide/unhide sheets for the respective user.

The userform closes at the end of this code however, this means that it closes before addins have loaded.

Is there a way for me to code: Once addins have loaded, close userform?

I attempted the Wait function however this doesn't work, this just delays the userform closing and therefore delays the addins being loaded.


Solution

  • Move your code currently in Workbook_Open to a separate "ContinueOpen" subroutine in a normal module. Then call this new routine from Workbook_Open, using Application.OnTime:

    Private Sub Workbook_Open()
        Application.OnTime Now, "'" & ThisWorkbook.FullName & "'!ContinueOpen"
    End Sub