Fix Excel VBA Image Not Updating on Combo Box Change
Question details
The user has an Excel VBA macro that loads a photo based on a combo box selection, but the image fails to refresh dynamically when a new option is chosen.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Using an ActiveX combo box to select different student profiles and load their corresponding photos from file paths stored in a worksheet.
- Observed behavior
- The macro loads the initial photo successfully into a shape but does not replace or update the image when a different student is selected from the combo box.
Ensure your macro security settings allow VBA code to run and verify that the image file paths stored in your worksheet column are completely accurate and accessible.
Use the ComboBox Change Event and Clear Previous Shapes
Trigger the macro directly from the ActiveX combo box change event and ensure the previous image shape is deleted before inserting a new one.
When inserting pictures as shapes in VBA, Excel stacks them on top of one another unless you delete the old shape first. Tying this deletion and recreation process to the combo box's Change event ensures the visual updates in real-time.
Press Alt + F11 to open the VBA Editor, then double-click the sheet containing your ActiveX combo box in the Project Explorer.
Ensure your code is placed inside the 'Private Sub ComboBox1_Change()' event block so it triggers automatically upon making a new selection.
Add a loop to locate and delete the existing image shape before inserting the new one. Loop through 'ActiveSheet.Shapes' and execute 'Shape.Delete' if the shape type is 'msoPicture' and matches the target area.
Use 'ActiveSheet.Pictures.Insert(imagePath)' to load the new student photo and set its Top and Left properties to position it correctly on the sheet.

Use an ActiveX Image Control Instead of Shapes
Using a dedicated ActiveX Image control is more reliable for dynamic picture updates than continually deleting and recreating shapes.
Seek Community Support for Complex VBA Debugging
If your code is complex and still fails to trigger, posting a reproducible example on a developer community like Stack Overflow is highly recommended.
Use WPS Spreadsheet for Robust VBA Macro Execution
WPS Office offers comprehensive support for Excel VBA macros, including ActiveX controls, user forms, and event-driven programming. You can run, edit, and debug your dynamic combo box image scripts natively within WPS Spreadsheet without worrying about compatibility issues.
- 1. Download and Install WPS Office: Download WPS Office from the official website and complete the quick installation process.
- 2. Open Your Macro-Enabled File: Launch WPS Spreadsheet and open your existing .xlsm file containing the VBA macros.
- 3. Enable Macros: Click 'Enable Macros' in the security prompt at the top of the screen to allow the ActiveX combo box to function.
- 4. Run and Debug: Test your combo box selections. You can press Alt + F11 to open the WPS VBA Editor to edit your image update code.

Frequently Asked Questions
Why is the LoadPicture function throwing an error in my VBA macro?
This usually happens if the file path provided in your worksheet column is incorrect, the image format is unsupported, or the image has been deleted from your local drive. Always verify that the path is absolute and accessible.
How do I ensure a macro triggers automatically when a combo box value changes?
You must use the Change event associated with that specific ActiveX control. Right-click the combo box while in Design Mode, select 'View Code', and place your macro execution commands inside the 'Private Sub ComboBox1_Change()' block.
Can WPS Office run Excel VBA macros that use ActiveX controls?
Yes, WPS Spreadsheet natively supports standard VBA macros and can seamlessly run scripts involving ActiveX controls like combo boxes and image controls, making it a highly compatible alternative to Microsoft Excel.




