VBA – Picture in ActiveX Control from Excel

Today I have tried for some time to do the following – make a picture ActiveX controller change, following the results of a dropdown button. The problem is that the picture ActiveX controller expects a path to the picture file, and I wanted the picture file to be in the Excel application itself. Otherwise, it is a little bit messy. All I have seen in the net was code, which was doing it really well, but considering the fact that the picture is outside. Thus, I have thought of going around it and doing the following:

  1. Add the picture in a picture ActiveX Controller in a user form.
  2. Call the picture from the userform into my Excel spreadsheet.
  3. Yup! Easy as this! 🙂

dropdow

The code is really not fascinating, but it works pretty well, without having to save the picture outside the file. Here is also a really small video of the functionalities:

How to change picture in Excel

And finally, the code come here:

Private Sub cmb_main_Change()
    
    Select Case cmb_main
    
        Case 1:
        img_main.Picture = uf.Image1.Picture
        Case 2:
        img_main.Picture = uf.Image2.Picture
        Case 3:
        img_main.Picture = uf.Image3.Picture
        Case 4:
        img_main.Picture = uf.Image4.Picture
        
    End Select
    
End Sub

And the file itself!

Enjoy it! 🙂