+ Reply to Thread
Results 1 to 12 of 12

ImageCombobox doesn't display images when Excel is opened

  1. #1
    Registered User
    Join Date
    02-15-2014
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    42

    ImageCombobox doesn't display images when Excel is opened

    Greetings everyone,

    I recently discovered the ImageComboBox to display images in a dropdown menu and this is something really handy. Unfortunately, I'm having issues to make it work properly.

    I have an ImageCombobox Control and an Imagelist Control.

    Imagelist Control:
    The pictures have been added to the Imagelist Control. Keys are labeled "A1" and "A2".

    ImageCombobox:
    In the properties, the image list has been set on "ImageList1" (name of the Imagelist Control).

    The VBA code I'm using:

    Private Sub Workbook_Open()

    With Sheets("Sheet1").ImageCombo1
    .ComboItems.Clear
    .ComboItems.Add 1, "A1", "", 1
    .ComboItems.Add 2, "A2", "", 2

    End With
    End Sub


    My problem:

    If I run the code, it's actually working. However, if I close the document and I reopen it, the images are no longer displayed in the dropdown menu.
    In order to display them again, I have to do the following:

    - Go to the ImageCombobox properties.
    - Set the image list to "none" and click "Apply.
    - Set the image list to "ImageList1" and click "OK".
    - Open the VBA code and press F5 to run the code.

    My guess is that I'm missing a trigger event but I thought that "Private Sub Workbook_Open()" was used as an event...

    May I ask if someone has any idea about what's wrong?
    Thanks in advance for your help.

  2. #2
    Registered User
    Join Date
    02-09-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    69

    Re: ImageCombobox doesn't display images when Excel is opened

    I've experienced the same thing in the past.

    I recall using the activate function in the end rather than the open.
    Might be worth a try.

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: ImageCombobox doesn't display images when Excel is opened

    Have you tried setting the ImageList property of the ImageCombo in the code?
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    02-15-2014
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    42

    Re: ImageCombobox doesn't display images when Excel is opened

    Quote Originally Posted by Norie View Post
    Have you tried setting the ImageList property of the ImageCombo in the code?
    Please Login or Register  to view this content.
    Thank you for your help. I'm afraid this code didn't change anything (I tried to copy it in "Sheet1" as well as "ThisWorkbook").

    As for the Activate function, I tried this "Private Sub Workbook_SheetActivate(ByVal Sh As Object)" but it didn't change anything...
    Am I doing something wrong?

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: ImageCombobox doesn't display images when Excel is opened

    Where have you put this code?

  6. #6
    Registered User
    Join Date
    02-15-2014
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    42

    Re: ImageCombobox doesn't display images when Excel is opened

    I did Alt+F11 to open the VBA editor and I put the code in "Sheet1" first. Since it didn't work, I put it in "ThisWorkbook".
    Sheet1 is where the Imagecombobox/ImageList are.

  7. #7
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: ImageCombobox doesn't display images when Excel is opened

    Try this

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  8. #8
    Registered User
    Join Date
    02-15-2014
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    42

    Re: ImageCombobox doesn't display images when Excel is opened

    Quote Originally Posted by Andy Pope View Post
    Try this

    Please Login or Register  to view this content.
    Thank you very much, this works.

    Now, I just have a last minor issue and I'd like to ask for your advice (so sorry for the trouble...).
    When I open the document, the images are now displayed in the combobox dropdown menu. However, the combobox size is reset and therefore is too small. Also the backcolor is reset (the color set seems random though...).

    Do you know if there is a setting for this to ensure that the height/width I specify doesn't reset when I reopen the document?
    I'm thinking about adding a macro to manually set the height/width but maybe I just missed something in the properties...

    Thanks again for your help.

  9. #9
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: ImageCombobox doesn't display images when Excel is opened

    I would set the properties in the code.

    Edit:
    Have you considered using the Ribbon to house your images in a gallery?
    Last edited by Andy Pope; 04-08-2014 at 08:05 AM.

  10. #10
    Registered User
    Join Date
    02-15-2014
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    42

    Re: ImageCombobox doesn't display images when Excel is opened

    I'm sorry, I don't know what you mean by housing the images in the gallery....

    Also, I use the following VBA to set the size and it works:

    ActiveSheet.Shapes.Range(Array("ImageCombo1", "ImageCombo2", "ImageCombo3")).Select
    Selection.ShapeRange.LockAspectRatio = msoFalse
    Selection.ShapeRange.Height = 28.5
    Selection.ShapeRange.Width = 39.75
    (I add it here in case someone find this thread and needs it).

    Now, my last problem is for the backcolour of the combobox (it's set randomly when I reopen the document).

    I tried "ImageCombo2.BackColor = &HEEF5F6" but Excel is not happy (Error 424, Object required).
    Isn't the "ImageCombo2" the object in this case?

    EDIT: Nevermind, I somehow manage to fix it with "Sheet4.ImageCombo2.BackColor = &HEEF5F6".

    Thank you very much everyone. I think I'm done for now.
    Last edited by DreamEyes; 04-08-2014 at 08:45 AM.

  11. #11
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: ImageCombobox doesn't display images when Excel is opened

    I mean use the ribbon rather than a non standard control on the worksheet.

    See the Gallery example on this page
    http://www.andypope.info/vba/ribboneditor.htm

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    02-15-2014
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    42

    Re: ImageCombobox doesn't display images when Excel is opened

    It turns out that the document still doesn't work because:

    1) Since the VBA includes "ImageList = Nothing", the images set previously before closing the document are not saved.
    2) For some reason, the code to resize the combobox works fine on my computer session but causes an error if someone else opens it.

    I think I'll look into the Gallery option and see if that could be an alternative.
    As always, thanks very much for your help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 4
    Last Post: 12-12-2012, 06:45 AM
  2. Can Images be opened from within Excel?
    By Rufius in forum Excel General
    Replies: 18
    Last Post: 09-16-2012, 06:15 AM
  3. [SOLVED] Opened Spreadsheet doesn't display
    By McGrinch in forum Excel General
    Replies: 2
    Last Post: 07-31-2006, 11:08 AM
  4. [SOLVED] Is there any way to display URL images in an Excel spreadsheet?
    By kennyharrill in forum Excel General
    Replies: 0
    Last Post: 03-13-2006, 05:10 PM
  5. [SOLVED] display hyperlinked images in an excel spreadsheet
    By ll in forum Excel General
    Replies: 0
    Last Post: 02-28-2006, 12:40 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1