This guide will explain how you can insert a specified picture into a UserForm in Excel.
UserForms are objects that can help data entry to sheets easier for the user. These UserForms are designed in the Visual Basic Editor and appear as a window or dialog box to the user.
UserForms are powerful and highly customizable objects that create a graphic interface for users to interact. They can hold various controls such as checkboxes, text boxes, and combo boxes. These elements are used to control user input.
Besides these controls, you also have the option to add images into your UserForm dialog box. Let’s take a look at a quick example of where we might need to use a Userform with an added picture.
Suppose we have a dialog box that requires the user to enter a code they have received in an email. To make it clear where to find the code, you would like to attach an image of a sample email with the code clearly encircled.
Adding a helpful image into your UserForms can prevent mistakes and allow the users to understand what to do clearly.
This example is just one use case for adding a picture to a UserForm in Excel. We can also use images to add branding to our UserForms or to add icons to help give users context.
Let’s learn how to create our own UserForms and find out how we can add our own images.
A Real Example of a UserForm with a Picture
Let’s take a look at a real example of an Excel UserForm with an added picture.
In the example below, we have a UserForm dialog box with a picture and a few OptionButton elements. This particular example tests the user’s familiarity with the artwork shown. The UserForm controls the response into three possible options.
In the second example below, we have a UserForm that asks the user for their Driver’s License ID. To help users locate the required information, we’ve added a sample license with the ID clearly marked. The UserForm also contains a label, a text box, and a command button.
You can make your own copy of the spreadsheet above using the link attached below.
Since UserForms require the Visual Basic Editor, you must use the Excel Desktop App to work with UserForms to your spreadsheets. Users cannot work with UserForms in the Microsoft Excel Online application.
If you’re ready to create your own UserForms dialog box in Excel, let’s begin writing it ourselves!
How to Insert a Specified Picture into a Userform in Excel
This section will explain each step needed to start using UserForms with embedded images in Excel. You’ll learn how we can use the Visual Basic Editor to insert a specified picture into our custom UserForm dialog box.
- First, go to the Developer tab and click on the Visual Basic icon. This will open the Visual Basic Editor in a separate window.
- Next, we hover over the Insert menu and click on the UserForm option.
- A new window should appear in the editor. The window will display a graphic representing how our UserForm currently looks. A toolbox window should also appear with various options for Control elements. Select the Image element icon as seen below.
- A blank image element should now appear in the UserForm window. You can resize both the image element and the UserForm window itself as needed.
- Next, click on the image area and look for the Properties panel on the left-hand side of the Visual Basic Editor.
- To add a new image, click on the ‘…’ icon on the far-right side of the Picture property.
- A document selection box will appear where you can navigate and select your preferred picture. Click on Open to select the picture.
- Next, we should change the PictureSizeMode property. The Stretch mode allows the entire image to be fit into the indicated area.
- Once the PictureSizeMode has been set to Stretch, your image should now fit inside your UserForm.
- You can now add other control elements to the Userform. In the example below, we’ve added OptionButtons underneath the image.
Frequently Asked Questions (FAQ)
- What types of file types are supported by Visual Basic?
Graphics formats that are recognized by Visual Basic include .bmp, .ico, .cur, .gif, and .jpg files. Note that .PNG files are not supported by Visual Basic. - Can I add an Image into a userform programmatically?
Yes. You can create custom VBA code that can dynamically add images to a given UserForm as needed.
That’s all you need to remember to insert a picture in a Userform in Excel. This step-by-step guide shows how easy it is to create a new UserForm in Excel and add images as a new element.
UserForms are just one way you can improve user input in your spreadsheets. With so many other Excel functions out there, you can surely find a few that can help improve your worksheets.
Are you interested in learning more about what Excel can do? Be sure to subscribe to our Excel newsletter to be the first to know about the latest guides and tutorials from us.