Splash screen when opening an Excel workbook

This trick will allow you to display a splash screen when you open any given workbook in Excel.

Splash screen when opening an Excel workbook

The splash screen appears immediately after opening the file and automatically disappears after a few seconds.

Step 1. Create a screen form

Open the Visual Basic Editor – in older versions of Excel, this can be done through the menu Service – Macro – Visual Basic Editor (Tools — Macro — Visual Basic Editor), and in the new button Visual Basic tab developer (Developer) and create a new form using the menu command Insert — UserForm. An empty gray window form of the future splash screen will appear. Add an image to it using the toolbar Toolbox (if you can’t see it, then go to the menu View — Toolbox):

Splash screen when opening an Excel workbook

Нажмите кнопку Image and drag a rectangle on the form – the background image will be placed in it. Then on the toolbar Properties (if you can’t see it, then select from the menu View — Properties) set select image file in the field Picture:

You may need to resize the form a bit to fit the image completely. To write text on the form, you can use the control Label with panels toolbox.

Well, finally, having previously selected the entire form, you can set the text in the title bar using the property Caption in the panel Properties:

As a result, you should get something like this:

Splash screen when opening an Excel workbook

Step 2. Add control code

Right click on the form and select View Code.In the form module that opens, add the following code:

   Private Sub UserForm_Activate()      Application.OnTime Now + TimeValue("00:00:05"), "KillTheForm"   End Sub

Open the module This book in the upper left corner (if it is not visible, display the corresponding window through the menu View — Project Explorer) and add the following code to it:

   Private Sub Workbook_Open()      UserForm1.Show   End Sub   

And finally, insert a regular module (Insert – Module) and copy this in there:

   Private Sub KillTheForm()      Unload UserForm1   End Sub   

All. You can close the Visual Basic editor, save the file and try to close-open the workbook…

How does it work?

When a workbook is opened, Excel executes a procedure Workbook_Open from the module This book. This procedure displays our splash form on the screen. When the form is displayed, the procedure is started UserForm_Activate, which runs the macro with a delay of 5 seconds KillTheForm, which removes the form from the screen.

  • What are macros, how to work with them, where to insert Visual Basic code

 

Leave a Reply