WebListBox Object

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Shape
Aa613228.parchild(en-us,office.10).gifWebListBox
Aa613228.space(en-us,office.10).gifAa613228.parchild(en-us,office.10).gifWebListBoxItems

Represents a Web list box control. The WebListBox object is a member of the Shape object.

Using the WebListBox object

Use the AddWebControl method to create a new Web list box. Use the WebListBox property to access a Web list box control shape. Use the AddItem method of the WebListBoxItems object to add items to a Web list box. This example creates a new Web list box and adds several items to it. Note that when initially created, a Web list box control contains three default items. This example includes a routine that deletes the default list box items before adding new items.

Note   When you create a Web list box, its initial width is 300 points. However, Microsoft Publisher automatically changes this width based on the width of the items in the list.

  Sub CreateWebListBox()
    Dim intCount As Integer
    With ActiveDocument.Pages(1).Shapes
        With .AddWebControl(Type:=pbWebControlListBox, Left:=100, _
                Top:=150, Width:=300, Height:=72).WebListBox
            .MultiSelect = msoFalse
            With .ListBoxItems
                For intCount = 1 To .Count
                    .Delete (1)
                Next
                .AddItem Item:="Green"
                .AddItem Item:="Purple"
                .AddItem Item:="Red"
                .AddItem Item:="Black"
            End With
        End With
    End With
End Sub