Microsoft Office Tutorials and References
In Depth Information
Maximizing Your UserForm’s Size
MAxiMizing your usErforM’s sizE
If you want to ill the screen with just your UserForm and nothing else, the following code in the
Initialize event can help you do that. Be aware that some adjustment to the code might be needed
with the Zoom property, in case the UserForm is so small to begin with that its fully expanded size
exceeds the window’s Zoom capacity.
Private Sub UserForm_Initialize()
With Application
.WindowState = xlMaximized
Zoom = Int(.Width / Me.Width * 100)
Width = .Width
Height = .Height
End With
End Sub
You don’t need to settle for the UserForm loading in the center of your screen.
You can specify the location, such as with the following example that shows the
UserForm in the top-left corner of the screen:
Private Sub UserForm_Initialize()
Me.StartUpPosition = 0
Me.Top = Application.Top
Me.Left = Application.Left
End Sub
sElEcTing And displAying pHoTogrApHs on A usErforM
An Image control helps you display a graphic object, such as a picture, on a UserForm. You have
three ways to place a picture onto an Image file — two are manual methods and one is a VBA
Suppose you have a picture file on your computer, such as your company’s logo, that you want to
show for a customized look on your UserForm. You can use VBA’s LoadPicture method to load the
picture file onto the Image control when you call the UserForm, with the following example:
Private Sub UserForm_Initialize()
Image1.Picture = LoadPicture(“C:\CompanyPictures\CompanyLogo.jpg”)
End Sub
This method works great, so long as the picture file exists in that folder path for every computer on
which the UserForm will ever be opened, which is not likely. As you develop UserForms for others’
use outside a shared network environment, you’ll want to manually load a picture onto an Image
control, and forego the VBA route.
Search JabSto ::

Custom Search