Skip to content

Latest commit

 

History

History
49 lines (37 loc) · 1.59 KB

how-to-add-a-control-to-a-multipage-control.md

File metadata and controls

49 lines (37 loc) · 1.59 KB
title keywords f1_keywords ms.assetid ms.date ms.localizationpriority
How to: Add a Control to a MultiPage Control
olfm10.chm3077153
olfm10.chm3077153
9fd9a559-ece9-26dd-047c-c3c649347257
06/08/2019
medium

Add a Control to a MultiPage Control

The following example uses the Add, Clear, and Remove methods of the Microsoft Forms 2.0 Controls collection to add a control to and remove a control from a Page of a MultiPage at run time.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • A MultiPage named MultiPage1.

  • Three CommandButton controls named CommandButton1 through CommandButton3.

Dim MyTextBox 
Dim MultiPage1 
 
Sub Item_Open() 
 Set MyPage = Item.GetInspector.ModifiedFormPages("P.2") 
 Set MultiPage1 = MyPage.MultiPage1 
 MyPage.CommandButton1.Caption = "Add control" 
 MyPage.CommandButton2.Caption = "Clear controls" 
 MyPage.CommandButton3.Caption = "Remove control" 
End Sub 
 
Sub CommandButton1_Click() 
 Set MyTextBox = MultiPage1.Pages(0).Controls.Add("Forms.TextBox.1", "MyTextBox", 1) 
End Sub 
 
Sub CommandButton2_Click() 
 MultiPage1.Pages(0).Controls.Clear 
End Sub 
 
Sub CommandButton3_Click() 
 If MultiPage1.Pages(0).Controls.Count > 0 Then 
 MultiPage1.Pages(0).Controls.Remove "MyTextBox" 
 End If 
End Sub

[!includeSupport and feedback]