+ Reply to Thread
Results 1 to 4 of 4

Listbox selected item not getting properly highlighted

  1. #1
    Registered User
    Join Date
    12-27-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2003
    Posts
    3

    Listbox selected item not getting properly highlighted

    This is just a post some maybe others will avoid wasting time and effort like I had to....

    It seems that when reloading a listbox (in my case in ppt, but triggered from vba in excel) the ppt application (office 2010) was not highlighting the selected row in the listbox, and was infact also losing the selected row information when the item lost focus.

    basic logic...
    indication in excel that new data is to be displayed
    triggers macro in ppt to fetch data and update:-
    1. select the userform and listbox
    2. fetch the data from excel worksheet range into a local array
    3. save locally the current selected index in the listbox
    4. reload the data into the listbox and adjust column widths
    5. relocate the old selected item, and set the new selected index

    after several hours of banging my head against a brick wall, i finally got the issue down to two lines of code, and the order in which they were used...

    Summary of key Code lines which did not work:
    Please Login or Register  to view this content.
    Code which worked fine:
    Please Login or Register  to view this content.

    So in summary, if you get problems with listbox selected items not being highlighted, double check you are not re-defining column widths after loading the data into the list.....
    Last edited by KeithDyne; 03-06-2013 at 10:43 AM.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Listbox selected item not getting properly highlighted

    Thank you for posting this. It will surely help someone.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    05-16-2014
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: Listbox selected item not getting properly highlighted

    Thank you! I am that someone!!

    This is an annoying bug. The ListIndex property is still correct, but the display not. Anyway, as suggested, I moved the ColumnWidth code before the populate code and it works fine.

  4. #4
    Registered User
    Join Date
    01-03-2016
    Location
    Singapore
    MS-Off Ver
    365 2016
    Posts
    1

    Re: Listbox selected item not getting properly highlighted

    Thank you. I experienced the same thing in Word. I had arrived at the same conclusion, but was looking for corroboration.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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