Use VBA to set ListBox properties

E

EE

I tried to set the width of a ListBox, according to the width of the data
using

ListBox_xx.Width = ...

This is done from within UserForm_Initialize.

It will only work if I have a breakpoint within UserForm_Initialize.
Otherwise the listbox will not display the size properly. I have set the
caption of the UserForm to ListBox_xx.Width, so I know it is set properly,
but not displayed.

I also tried to set the font to a fixed font (Courier new). Once I do this,
the setting of ListBox_xx.ListIndex does not work at all, even with the
breakpoint that allows the width to be set. here too, I wrote the ListIndex
on the caption, so i know it was set, just not displayed.

Any ideas ?
 
C

Chris Roth [MVP]

If the ListBox is on a Visio Page, then it is wrapped inside of a Visio
shape, and the "VBA Width" is a different animal at this point.

To set a shape's width, you do something like this:

visShpLst.Cells("Width").ResultIU = 3
' this value is inches

visShpLst.Cells("Width").Formula = "3 mm"
' Formula is a string - anything that is valid in the ShapeSheet will work
here

--
Hope this helps,

Chris Roth
Visio MVP

More Visio shapes, articles, development info and pure diagramming fun at:
www.visguy.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top