Shapes.AddWebControl 方法 (Publisher)
將代表 Web 表單控制項的新 Shape 物件加入至指定 的 Shapes 集合。
語法
運算式。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 會發生錯誤。 |
傳回值
圖形
註解
對於 Left、 Top、 Width和 Height 參數,數值會以 點為單位進行評估;字串可以是 Microsoft Publisher (支援的任何單位,例如「2.5 in」) 。
使用 pbWebControlHotSpot 常數將作用點新增至 Web 控制項時,URL 是由 Hyperlinks 屬性指定。
請注意無法存取 Shape.Fill 屬性,它會傳回 FillFormat 物件,並傳回 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 出版物第四頁的圖案中新增作用點。 首先,四點星形快取圖案會新增至頁面。 接下來,使用AddWebControl方法搭配pbWebControlHotSpot類型,將作用點新增至星形的每個 Arm。 最後,使用每個作用點圖形的 Hyperlinks 屬性,將超連結新增至每個作用點。
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 支援與意見反應。