How to Insert a Picture in a VBA UserForm in Excel 365

VBA & macros · Updated November 3, 2026

How to Insert a Picture in a VBA UserForm in Excel 365

To insert a picture in an Excel VBA UserForm, open the Visual Basic Editor, add an Image control from the Toolbox, then either select a file in the control’s Picture property or load it with VBA’s LoadPicture function. The first option keeps the picture with the form; the code option loads it when the form opens and normally requires the image file to remain available.

What You’ll Need

  • Excel desktop for Microsoft 365 on Windows. Excel for the web cannot create or run VBA UserForms.
  • A workbook saved as an Excel Macro-Enabled Workbook (.xlsm) if it contains VBA.
  • A picture file. BMP, JPG, and GIF are sensible formats to try first; PNG support can vary with the MSForms picture loader, so convert a PNG to JPG or BMP if it will not load.
  • Access to the Visual Basic Editor and its UserForm designer. If the Developer tab is hidden, enable it from File > Options > Customize Ribbon and select Developer.

Step-by-Step

  1. Save a copy of the workbook first. VBA changes and macros cannot be undone with Ctrl+Z. Save a working copy as an .xlsm file using File > Save As, then choose Excel Macro-Enabled Workbook. Keep the original unchanged while you set up the form.
  2. Open the Visual Basic Editor. In Excel for Windows, press Alt+F11, or select Developer > Visual Basic. If you use a Mac, the Visual Basic Editor is available in desktop Excel, but shortcuts, dialog locations, and some UserForm control behavior differ; Excel for the web does not provide the VBA editor.
  3. Create or open a UserForm. In the editor, find your workbook in Project Explorer. If that pane is not visible, select View > Project Explorer. To add a form, select Insert > UserForm. To edit an existing one, double-click its name, such as UserForm1. The form designer appears with a Toolbox; if it is hidden, choose View > Toolbox.
  4. Add an Image control. In the Toolbox, select the Image control, usually shown as a small picture icon, then click and drag on the UserForm to draw a rectangle. The picture will display inside this rectangle. Select the control and use the Properties window to confirm its name, typically Image1. If Properties is not visible, choose View > Properties Window.
  5. Choose the picture in the designer. With the Image control selected, find the Picture property in the Properties window. Click its value cell and then the ellipsis button that appears. Browse to the image, select it, and confirm. The picture should appear inside the control in the designer. This design-time method is convenient for a fixed logo or illustration because the picture is saved as part of the form in the VBA project; users do not need a separate copy of that image file at run time.
  6. Set how the picture fits. In the same Properties window, find PictureSizeMode. Choose fmPictureSizeModeZoom to show the whole image while preserving its proportions. Choose fmPictureSizeModeStretch if it is acceptable to fill the control even when that distorts the image. fmPictureSizeModeClip displays the image at its original size and clips parts that do not fit. Zoom is generally the safest choice for photographs and logos.
  7. Adjust the control and form. Drag the Image control’s handles to change its size and position. Use a control that has roughly the same proportions as the picture if you want to avoid empty space around a zoomed image. To resize the UserForm itself, select an empty area of the form and adjust its dimensions in Properties. Save the VBA project with Ctrl+S.
  8. Test the form. In the editor, press F5 while the UserForm is active, or use Run > Run Sub/UserForm. Check that the entire picture appears at a useful size and that other controls remain accessible. Close the form, make any adjustments in the designer, save again, and test the form from the workbook before sharing it.

Use the following alternative when the picture should be loaded at run time rather than selected in the designer. Add an Image control named Image1, then double-click an empty area of the UserForm to open its code window. Put this event procedure in that form’s code module, not in a worksheet module or a standard module. The example expects logo.jpg in the same folder as the workbook.

Before running or distributing a macro-enabled workbook, keep a backup copy. Ctrl+Z does not reverse changes made by a macro.

Private Sub UserForm_Initialize()
    Dim picturePath As String

    ' Require a saved workbook so its folder is available.
    If Len(ThisWorkbook.Path) = 0 Then
        MsgBox "Save the workbook before loading the picture.", vbExclamation
        Exit Sub
    End If

    ' Look for logo.jpg beside the workbook.
    picturePath = ThisWorkbook.Path & Application.PathSeparator & "logo.jpg"

    If Len(Dir$(picturePath)) = 0 Then
        MsgBox "Picture not found: " & picturePath, vbExclamation
        Exit Sub
    End If

    On Error GoTo PictureError
    Me.Image1.Picture = LoadPicture(picturePath)
    Me.Image1.PictureSizeMode = fmPictureSizeModeZoom
    Exit Sub

PictureError:
    MsgBox "The picture could not be loaded: " & Err.Description, vbExclamation
End Sub

Replace logo.jpg with the exact file name and extension. The code expects the control to be named Image1; if you renamed it, update Me.Image1 to match. A picture loaded from a path is not packaged into the UserForm by this code, so the file must remain at that location. If you move the workbook or send it to someone else, include the picture and keep the relative folder arrangement, or use the design-time Picture property instead.

Common Mistakes

  • Using a Label instead of an Image control. A Label is mainly for text and is not the normal control for displaying a picture. Add an Image control from the Toolbox.
  • Putting the event procedure in the wrong module. UserForm_Initialize belongs in the code module for the form that contains the Image control. A procedure in a worksheet module will not run when that form initializes.
  • Assuming a run-time picture is embedded. LoadPicture reads a file from a path. If the file is moved, renamed, or unavailable to another user, the form cannot load it. For a fixed image, select it in the control’s Picture property at design time.
  • Using a file format the loader cannot read. If an image appears in the designer but fails with LoadPicture, try saving a copy as JPG or BMP. File extensions should match the actual image format, not just be renamed.
  • Choosing Stretch without checking the result. Stretch fills the control but can make faces, logos, or charts look unnaturally wide or tall. Use Zoom when preserving proportions matters.
  • Forgetting to save as a macro-enabled workbook. Saving a VBA project in a macro-free .xlsx file removes the VBA project. Use .xlsm for a workbook that needs its form and code.

Tips

  • Give the control a descriptive name, such as imgCompanyLogo, in its (Name) property. In code, use that same name. This makes forms with several pictures easier to maintain.
  • Use the smallest image dimensions that still look clear at the size shown on the form. Oversized photos can increase workbook file size and make the form slower to load.
  • For a picture that changes depending on a selection, keep the Image control on the form and assign a different picture to its Picture property when the selection changes. Check that each file exists before calling LoadPicture, and handle errors so a missing file does not stop the form unexpectedly.
  • For a set of fixed images, add them through the Picture property in the designer. That avoids depending on a user-specific folder path and makes distribution simpler, though it can increase the workbook’s size.
  • Test the form on the same operating system and Office environment used by the people who will open it. Excel for Mac has VBA, but UserForm support and picture-loading details may differ from Windows. Excel for the web cannot run the VBA form.

Troubleshooting

The Picture property has no ellipsis or the dialog will not open: select the Image control itself, not the form or another control, and make sure the Properties window is open. Click the value cell beside Picture; the browse button appears there. If the control is not selected, its properties will not be shown.

The picture does not appear in the designer: verify that the file opens in another application, then try a BMP or JPG copy. Confirm that the correct Image control is selected and that its dimensions are not tiny. If you added the picture by code, remember that the designer does not run UserForm_Initialize; run the form with F5 to see the run-time image.

The form opens but displays a file-not-found message: check the workbook’s saved folder, the exact spelling and extension, and the code’s expected location. If the picture is in a subfolder named Images, include that folder in the path expression. Save the workbook before testing because an unsaved workbook has no usable folder path in ThisWorkbook.Path.

LoadPicture reports an error even though the file exists: the path may point to an unsupported or damaged image, or the extension may not match its format. Try a fresh JPG or BMP export and verify the full path. If the file is on a network, cloud, or removable drive, first copy it to a simple local folder to rule out access or synchronization issues.

The image looks distorted, cropped, or blank: review PictureSizeMode. Use Zoom to preserve the image’s proportions, Stretch only when distortion is acceptable, and Clip when you intentionally want a cropped view. Also check that the Image control is large enough and is not covered by another control. Save, close, and reopen the form after changing its design-time picture.

The macro does not run: save the workbook as .xlsm, reopen it in desktop Excel, and enable macros only if you trust the file. Confirm that the code is in the correct UserForm module and that the control name in the code matches its (Name) property exactly. Macro security settings may prevent the form’s initialization procedure from running.

Frequently Asked Questions

Can I insert a picture without writing VBA?
Yes. Add an Image control in the UserForm designer and select the file through its Picture property. That is usually the simplest approach for an image that never changes.

Does the picture stay in the workbook?
A picture selected through the control’s design-time Picture property is stored with the UserForm project. A picture assigned using LoadPicture at run time is read from its external file path, so that file must remain available.

Can I use PNG in a VBA UserForm?
PNG loading can vary with the MSForms control and Office environment. If a PNG fails to display, convert it to JPG or BMP and try again. Do not assume that changing the file extension converts the image.

How do I make the picture fit without distortion?
Set the Image control’s PictureSizeMode property to fmPictureSizeModeZoom. This shows the whole picture while maintaining its proportions, although it may leave unused space on one side.

Can a UserForm picture change while the form is open?
Yes. VBA can assign a new picture to the Image control’s Picture property when an event occurs, such as a button click or selection change. Check that the new image path exists and use a compatible format.

Will the form work in Excel for the web?
No. Excel for the web can open an .xlsm workbook, but it cannot run VBA macros or display a VBA UserForm as an interactive form. Use desktop Excel to run it.

Related

Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.

More in VBA & macros

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.