Microsoft Office Tutorials and References
In Depth Information
Unloading a UserForm Automatically
You can manually load an Image control in two ways. In the
UserForm’s design window, place the Image control where you want
it on the UserForm. Activate the Image control’s Properties window
and locate the Picture property. Placing your cursor inside the
Picture property will expose a small ellipsis button, as shown in
Figure 20-3. Click that button to show the Load Picture dialog box.
From the LoadPicture dialog box, navigate to the picture file you
want to load, select it, and click the Open button.
The other manual alternative is even simpler. After you’ve added
your Image control, select your Picture object and press Ctrl+C
to place it onto the clipboard. Select the Image control on the
UserForm, select its Picture property in the Properties window,
click inside the Picture property, and press Ctrl+V to paste the
picture into the Image control.
figurE 20-3
unloAding A usErforM AuToMATicAlly
Have you ever wanted to show a UserForm for a limited period of time, and then unload it without
user intervention? UserForms need not serve the sole purpose of user input. Sometimes they can be
opportunistically employed as a mechanism for a specialized greeting, or, if tastefully designed, an
informative splash screen.
Personally, I do not appreciate most of the splash screens I see when opening various software
applications; many look like cheap advertisements that waste the user’s time. However, a nice opening
welcome message to customize the look and feel of your workbook can be a good thing if designed
well, but do keep the visible time to a maximum of five seconds — any longer than that is an
annoyance.
Call the UserForm as you normally would. The following code goes into the UserForm module, in
this example for a five-second appearance:
Private Sub UserForm_Activate()
Application.Wait (Now + TimeValue(“0:00:05”))
Unload Me
End Sub
prE-sorTing THE lisTBox And coMBoBox iTEMs
Suppose you want to import a list of items into your ListBox (or ComboBox) such as a list of cities
in range A1:A20 as shown in Figure 20-4. You can do that easily with this event code for a ListBox:
Private Sub UserForm_Initialize()
ListBox1.List = Range(“A1:A20”).Value
End Sub
 
Search JabSto ::




Custom Search