VBA & Macro Problems

How to Add Image Upload Functionality to an Excel UserForm in WPS Spreadsheets

Jason MillerJason Miller Nov 13, 2026 869 views

Question details

The user needs to add a click-to-upload image picker to an Excel UserForm so users can select and preview an image inside the form.

How to Add Image Upload Functionality to an Excel UserForm with VBA
Product
WPS Spreadsheets (Excel-compatible)
Device & OS
not provided
Scenario
A user is designing a UserForm and wants a command button to open a file picker, filter image files, and display the selected picture in an Image control.
Observed behavior
The Image ActiveX control itself does not provide a built-in upload or file-picker interface, so the form cannot load an image without VBA code.
Before you start

Make sure the workbook is saved as a macro-enabled file type such as .xlsm and that the Developer tab or Visual Basic Editor is available before editing the UserForm.

Solution 1Recommended

Add a VBA file picker to an Excel UserForm image control

Use this approach when you need a click-to-upload image control in Excel because the Image ActiveX control does not include a built-in file picker.

The Excel Image ActiveX control can display a picture, but it does not expose the upload dialog that the Word control offers. A CommandButton with VBA code handles the file selection and assigns the selected image to the Image control.

1
Open the UserForm in the Visual Basic Editor

Open the macro-enabled workbook in WPS Spreadsheets or Excel, press Alt+F11 to open the Visual Basic Editor, then open or insert the UserForm where the image upload control is needed.

2
Add the Image control and command button

With the UserForm active, drag an Image control from the Toolbox onto the form, then drag a CommandButton next to it and set the button caption to Upload Image in the Properties window.

3
Add the VBA file picker code

Double-click the CommandButton to open the UserForm code module and paste the Click event code that uses Application.FileDialog(msoFileDialogFilePicker) to filter image types and sets Me.Image1.Picture = LoadPicture(filePath).

4
Run and test the UserForm

Press F5 to run the UserForm, click the Upload Image button, choose a supported image file such as JPG, PNG, GIF, or BMP, and confirm that the selected picture appears in the Image control.

Add a VBA file picker to an Excel UserForm image control
Image upload is ready: After the code is in place, the button opens a filtered file picker and displays the selected image in the form.

Create an Excel-compatible image upload UserForm in WPS Spreadsheets

Use WPS Spreadsheets to open macro-enabled workbooks, add a UserForm with an Image control and CommandButton, and run VBA that opens a file picker so users can select and preview images without changing to another Office suite.

  1. 1. Open the macro-enabled workbook in WPS Spreadsheets: Launch WPS Office and open the .xlsm workbook that contains the UserForm or create a new macro-enabled workbook.
  2. 2. Create or open the UserForm: Press Alt+F11 to open the VBA editor, then open the existing UserForm or insert a new UserForm from the Insert menu.
  3. 3. Add the image controls: Add an Image control and a CommandButton to the UserForm from the Toolbox, and set the button caption to Upload Image.
  4. 4. Paste the VBA picker code: Double-click the button and add the code that calls Application.FileDialog(msoFileDialogFilePicker), filters image types, and loads the selected file into Me.Image1.Picture.
  5. 5. Save and run the UserForm: Save the workbook as macro-enabled, then press F5 to test the button and confirm the selected image appears.
Implements the image upload workflow with familiar Excel VBA codeSupports macro-enabled .xlsm workbooks and Excel format compatibilityFree, lightweight Office suite with a familiar ribbon and VBA editorRuns existing spreadsheet macros without requiring a paid Microsoft 365 subscription
QA img-9

Frequently Asked Questions

Why doesn't the Excel Image ActiveX control show an upload button like Word?

The Excel Image ActiveX control can display pictures, but it does not include the built-in file picker interface found in Word. You need to add a CommandButton and use VBA to open the file dialog.

Can I filter the file dialog to only show image files?

Yes. In the Application.FileDialog object, use Filters.Clear and then Filters.Add "Images", "*.jpg;*.jpeg;*.png;*.gif;*.bmp" so users only see supported image types.

What file types can LoadPicture display in an Excel UserForm?

Common supported types include JPG, JPEG, PNG, GIF, and BMP. Unsupported or corrupt files can raise an error, so add error handling around the LoadPicture call.

Do I need a macro-enabled workbook for this image upload UserForm?

Yes. The VBA code requires macros, so save the workbook in a macro-enabled format such as .xlsm. Otherwise the code will not run.

Where should the VBA file picker code be placed?

Place the code in the CommandButton Click event inside the UserForm code module, not in a standard module, so it runs when the button is clicked.