I have an excel sheet with multiple listboxes. All of them multi-select. As excel always messes up the dimensions of the listboxes i had a piece of code to repair them when opening the workbook:
Private Sub Workbook_Open()
Dim Ctrl As OLEObject
For Each Ctrl In Sheets("SomeSheet").OLEObjects
If Ctrl.progID = "Forms.ListBox.1" Then
With Ctrl
.Width = 95.4
.Height = 70.2
End With
End If
Next Ctrl
End Sub
However after a while i noticed that the last entry is at best partially visible. A search on the interweb provided me with a solution : link.
Unfortunately that solution does not work for me. I adapted the above code to:
Private Sub Workbook_Open()
Dim Ctrl As OLEObject
Application.ScreenUpdating = False
For Each Ctrl In Sheets("SomeSheet").OLEObjects
If Ctrl.progID = "Forms.ListBox.1" Then
With Ctrl
.Object.IntegralHeight = False
.Width = 95.4
.Height = 70.2
.Object.IntegralHeight = True
.Object.MultiSelect = fmMultiSelectSingle
.Object.MultiSelect = fmMultiSelectExtended
End With
End If
Next Ctrl
End Sub
The result is that the width and height i have set are again screwed up by excel, as soon as the three statements following the .height are executed. With each statement resulting in a further shrinking of the listbox in both dimensions. To make matters worse they also move away from their position.
I'm looking for any clues how to fix this, so to have listboxes of the desired dimension, with all entries visible.
Edit 20140905 As per request a screenshot is added. Even though the scrollbar suggest i can scroll down further, that is not possible. As you can see by the blue color, 'Orange' is there, and is selected, and is in the listbox.