If you have created an interesting Excel workbook you share with others what software developers call an ‘application’ then it deserves a title or splash screen that appears for a few seconds when the file is opened. You can make it happen with a few short macros.
Press Alt & F11 to open the VBA for Excel editor. On the Insert menu, choose UserForm. With the mouse, drag the bottom right-hand corner out to increase the blank form.
This is so that your title page will appear at a good size when superimposed over the first worksheet of your application.
Drag the displayed toolbox into a convenient position. Click the large capital A in the toolbox to select the Label control. Drag out a Label box on the UserForm. Delete the text, Label 1 and type your main title in this label.
If the Label 1 Properties window isn’t showing, press F4. Now you have a wide
variety of options for creating a design. The default Font is probably Tahoma.
Click on that and a Font dialogue box appears.
The example here uses Arial Black, Regular, 72 point. Go to TextAlign and
choose, Center. Go to ForeColor, ButtonText, Palette, and choose a colour.
You can’t specify two different fonts within one label, so for the next line click on the cap A in the toolbox again and draw a second label. The Properties list will now be headed Label 2, so off you go again and type in the second line of your title page and format it differently but using the same procedures. If you have a third line, as in the finished example shown, create and format Label 3.
To colour in the background, click outside the labels but inside the UserForm and choose BackColor, Palette from the Properties list. For continuity, match this BackColor for each of the three labels.
One last thing. At the moment the top of your page says, UserForm 1. You really don’t want that appearing on your title page. Something more appropriate would be better.
At the top of the Properties list, change Name from UserForm 1 to Intro. Further down, also change Caption to Intro.
That’s the design created. Now all you have to do is make arrangements for it to appear. Double-click on the UserForm and in the Intro Code window click on the down arrow at the top right. Select Initialize. Complete the resulting code listing so it reads:
Private Sub UserForm_Initialize()
Application.OnTime Now + TimeValue(“00:00:04”), “ClearForm”
End Sub
This macro controls the amount of time the title page appears. In this example it’s for four seconds. You don’t want it to appear for much longer than it takes to read or the user will wonder what they are supposed to do next. On the VBA Insert menu select, Module and enter this code:
Sub ClearForm()
Unload Intro
End Sub
This establishes ClearForm as the macro to run after four seconds. Intro is the new Name for the default UserForm 1.
Finally, in the Project Explorer select ThisWorkbook. If the Project Explorer isn’t showing, press Ctrl & R. Enter:
Private Sub Workbook_Open()
Intro.Show
End Sub
Press Alt & F11 to return to your Excel workbook. Save the file. In the case of Excel 2007, save it as an .xlsm file, which will allow macros to be run. Close the workbook. If you have followed all the above instructions, the next time you open the file the title page will briefly appear.






reader comments