Publisher) (Shapes.AddWebControl 方法

將代表網頁表單控制項的新 Shape 物件新增至指定的 Shapes 集合。

語法

運算式。AddWebControl (類型, 左, 頂, 寬,高, LaunchPropertiesWindow)

expression 代表 Shapes 物件的變數。

參數

名稱 必要/選用 資料類型 描述
Type 必要 PbWebControlType 指定要新增的網頁表單控制項類型。 可以是 Microsoft Publisher 類型程式庫中宣告的其中一個 PbWebControlType 常數。 如果使用 pbWebControlWebComponent, 會發生錯誤。
Left 必要 Variant 代表網頁表單控制項之圖形左邊緣的位置。
Top 必要 Variant 代表網頁表單控制項之圖形頂端邊緣的位置。
Width 必要 Variant 代表 Web 表單控制項的圖形寬度。 用於命令按鈕時,會忽略此參數。
Height 必要 Variant 代表網頁表單控制項的圖形高度。 用於命令按鈕時,會忽略此參數。
LaunchPropertiesWindow 選用 Boolean 不支援。 預設值為 False ;如果此引數設為 True 會發生錯誤。

傳回值

圖形

註解

對於 Left、 Top、 Width 和 Height 參數,數值以 點為單位評估;字串可以使用 Microsoft Publisher (支援的任何單位,例如 “2.5 in”) 。

使用 pbWebControlHotSpot 常數將熱點新增到 Web 控制項時,URL 是由 [超連結 ] 屬性指定。

請注意無法存取 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) 


下列範例會將熱點新增到作用中網頁出版物第四頁的圖形。 首先,四點星形快取圖案會新增至頁面。 接下來,使用 AddWebControl 方法搭配 pbWebControlHotSpot類型,將熱點新增到恆星的每個臂。 最後,利用每個熱點圖形的 [超連結 ] 屬性,將超連結新增至每個熱點。

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 支援與意見反應。