Publisher) (Shapes.AddWebControl 方法

向指定的 Shapes 集合添加表示 Web 窗体控件的新 Shape 对象。

语法

表达式。AddWebControl (Type, left, top, width, height, LaunchPropertiesWindow)

expression:一个表示 Shapes 对象的变量。

参数

名称 必需/可选 数据类型 说明
Type 必需 PbWebControlType 指定要添加的 Web 窗体控件的类型。 可以是 Microsoft Publisher 类型库中声明的 PbWebControlType 常量之一。 如果使用 pbWebControlWebComponent ,则会发生错误。
Left 必需 Variant 表示 Web 窗体控件的形状左边缘的位置。
Top 必需 Variant 表示 Web 窗体控件的形状上边缘的位置。
Width 必需 Variant 表示 Web 窗体控件的形状的宽度。 对于命令按钮,此参数将被忽略。
Height 必需 Variant 表示 Web 窗体控件的形状的高度。 对于命令按钮,此参数将被忽略。
LaunchPropertiesWindow 可选 Boolean 不受支持。 默认值为 False;如果此参数设置为 True ,就会出错。

返回值

Shape

说明

对于 Left、 Top、 Width 和 Height 参数,数值以 点为单位计算;字符串可以采用 Microsoft Publisher (支持的任何单位,例如,“2.5 in”) 。

使用 pbWebControlHotSpot 常量将热点添加到 Web 控件时,URL 由 Hyperlinks 属性指定。

请注意,不能从热点形状访问的 Shape.Fill 属性,它返回的 相关 对象,并返回 LineFormat 对象, Shape.Line 属性。 如果试图从热点形状来访问这些属性,则返回运行时错误。

示例

以下示例将 Web 窗体检查框控件添加到活动发布的第一页。

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


以下示例将热点添加到活动 Web 出版物的第 4 页的形状中。 首先,四角星自选图形添加到页中。 接下来,通过使用类型为 pbWebControlHotSpot 的 AddWebControl 方法,向恒星的每个臂添加一个热点。 最后,使用每个热点形状的 超链接 属性将超链接添加到每个热点。

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 = "https://www.contoso.com/page1.htm" 
 End With 
 
 Set theWC2 = .AddWebControl(Type:=pbWebControlHotSpot, _ 
 Left:=320, Top:=105, Width:=80, Height:=40) 
 With theWC2 
 .Hyperlink.Address = "https://www.contoso.com/page2.htm" 
 End With 
 
 Set theWC3 = .AddWebControl(Type:=pbWebControlHotSpot, _ 
 Left:=280, Top:=145, Width:=40, Height:=80) 
 With theWC3 
 .Hyperlink.Address = "https://www.contoso.com/page3.htm" 
 End With 
 
 Set theWC4 = .AddWebControl(Type:=pbWebControlHotSpot, _ 
 Left:=200, Top:=105, Width:=80, Height:=40) 
 With theWC4 
 .Hyperlink.Address = "https://www.contoso.com/page4.htm" 
 End With 
End With

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。