AddWebControl Method

Microsoft Publisher Visual Basic

expression.AddWebControl(Type, Left, Top, Width, Height, LaunchPropertiesWindow)

expression    Required. An expression that returns one of the objects in the Applies To list.

Type   Required PbWebControlType. Specifies the type of Web form control to add. An error occurs if pbWebControlWebComponent is used.

PbWebControlType can be one of these PbWebControlType constants.
pbWebControlCheckBox Adds a check box.
pbWebControlCommandButton Adds a command button.
pbWebControlHotSpot Adds a hot spot.
pbWebControlHTMLFragment Adds an HTML fragment.
pbWebControlListBox Adds a list box.
pbWebControlMultiLineTextBox Adds a multiple-line text area.
pbWebControlOptionButton Adds an option button.
pbWebControlSingleLineTextBox Adds a single-line text box.
pbWebControlWebComponent Not used for this method.

Left   Required Variant. The position of the left edge of the shape representing the Web form control.

Top   Required Variant. The position of the top edge of the shape representing the Web form control.

Width   Required Variant. The width of the shape representing the Web form control. For command buttons, this parameter is ignored.

Height   Required Variant. The height of the shape representing the Web form control. For command buttons, this parameter is ignored.

LaunchPropertiesWindow   Optional Boolean. Not supported. Default is False; an error occurs if this argument is set to True.

Remarks

For the Left, Top, Width, and Height arguments, numeric values are evaluated in points; strings can be in any units supported by Publisher (for example, "2.5 in").

When adding a hot spot to a Web control by using the pbWebControlHotSpot constant, the URL is specified by the Hyperlink property.

Note that the Shape.Fill property, which returns a FillFormat object, and the Shape.Line property, which returns a LineFormat object, cannot be accessed from a hot spot shape. A run-time error is returned if attempting to access these properties from a hot spot shape.

Example

The following example adds a Web form check box control to the first page of the active publication.

Dim shpCheckBox As Shape

Set shpCheckBox = ActiveDocument.Pages(1).Shapes.AddWebControl _
    (Type:=pbWebControlCheckBox, _
    Left:=216, Top:=216, _
    Width:=18, Height:=18)

		

The following example adds hot spots to a shape on page four of the active Web publication. First, a four-point star AutoShape is added to the page. Next, a hot spot is added to each arm of the star by using the AddWebControl method with a Type of pbWebControlHotSpot. Finally, a hyperlink is added to each hot spot by using the Hyperlink property of each hot spot shape.

Dim theDoc As Document
Dim theStar As Shape
Dim theWC1 As Shape
Dim theWC2 As Shape
Dim theWC3 As Shape
Dim theWC4 As Shape

Set theDoc = ActiveDocument
Set theStar = theDoc.Pages(4).Shapes.AddShape _
        (Type:=msoShape4pointStar, Left:=200, Top:=25, _
        Width:=200, Height:=200)

With theDoc.Pages(4).Shapes
    
    Set theWC1 = .addWebControl(Type:=pbWebControlHotSpot, _
        Left:=280, Top:=25, Width:=40, Height:=80)
        With theWC1
            .Hyperlink.Address = "http://www.contoso.com/page1.htm"
        End With
    
    Set theWC2 = .addWebControl(Type:=pbWebControlHotSpot, _
        Left:=320, Top:=105, Width:=80, Height:=40)
        With theWC2
            .Hyperlink.Address = "http://www.contoso.com/page2.htm"
        End With
    
    Set theWC3 = .addWebControl(Type:=pbWebControlHotSpot, _
        Left:=280, Top:=145, Width:=40, Height:=80)
        With theWC3
            .Hyperlink.Address = "http://www.contoso.com/page3.htm"
        End With
        
    Set theWC4 = .addWebControl(Type:=pbWebControlHotSpot, _
        Left:=200, Top:=105, Width:=80, Height:=40)
        With theWC4
            .Hyperlink.Address = "http://www.contoso.com/page4.htm"
        End With
End With