Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

How to use Microsoft Forms 2.0 ActiveX Controls in FrontPage 2000


View products that this article applies to.

This article was previously published under Q208272
For a Microsoft FrontPage 98 version of this article, see 180822 (http://support.microsoft.com/kb/180822/ ) .

For a Microsoft FrontPage 97 version of this article, see 171673 (http://support.microsoft.com/kb/171673/ ) .
For a Microsoft FrontPage 98 version of this article, see 180822 (http://support.microsoft.com/kb/180822/ ) .
For a Microsoft FrontPage 97 version of this article, see 171673 (http://support.microsoft.com/kb/171673/ ) .

↑ Back to the top


Summary

This article describes how to insert Microsoft Forms 2.0 ActiveX controls in Microsoft FrontPage. In addition, the examples use Microsoft Visual Basic Scripting Edition (VBScript) code to set properties and respond to control events.

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

Microsoft Forms 2.0 ActiveX Controls

The Microsoft Forms 2.0 ActiveX Controls described in this article are included with Microsoft FrontPage.

NOTE: Microsoft Forms 2.0 Controls are not placed automatically in the Insert ActiveX Control list. To do this, click Customize in the Insert ActiveX Control dialog box, select the appropriate control, and then click OK.

Message Box Example

  1. On the Insert menu, point to Advanced, and then click ActiveX Control.
  2. In the Select A Control list, select Microsoft Forms 2.0 CommandButton.
  3. Click OK.
  4. Right-click the ActiveX Control, and then click ActiveX Control Properties on the menu that appears.
  5. In the Name box, type CommandButton1. Click OK.
  6. On the Tools menu, point to Macro, and then click Microsoft Script Editor.
  7. On the HTML menu, point to Script Block, and then click Server.
  8. Type the following code between the Script tags:
              Sub CommandButton1_Click()
                 ' Displays a message box with text when the command
                 ' button is clicked.
                 Msgbox "Hello World"
              End sub
    					

Label Example

  1. To insert a Microsoft Forms 2.0 Label, follow these steps:
    1. On the Insert menu, point to Advanced, and then click ActiveX Control.
    2. In the Select A Control list, click to select Microsoft Forms 2.0 Label.
    3. Click OK.
    4. Right-click the ActiveX Control, and click ActiveX Control Properties on the menu that appears.
    5. In the Name box, type Label1. Click OK.
  2. To insert a Microsoft Forms 2.0 command button, follow these steps:
    1. On the Insert menu, point to Advanced, and then click ActiveX Control.
    2. In the Select A Control list, select Microsoft Forms 2.0 CommandButton.
    3. Click OK.
    4. Right-click the ActiveX Control, and click ActiveX Control Properties on the menu that appears.
    5. In the Name box, type CommandButton2. Click OK.
  3. On the Tools menu, point to Macro, and then click Microsoft Script Editor.
  4. On the HTML menu, point to Script Block, and then click Server.
  5. Type the following code between the Script tags:
              Sub CommandButton2_Click()
                 ' The following example fills a Label control with text
                 ' when you click the command button.
                 Label1.Caption="Hello World" 
              End sub
    					

Text Box Example

  1. To insert a Text Box, follow these steps:
    1. On the Insert menu, point to Advanced, and click ActiveX Control.
    2. In the Select A Control list, click to select Microsoft Forms 2.0 TextBox. Click OK.
    3. Right-click the ActiveX Control, and then click ActiveX Control Properties on the menu that appears.
    4. In the Name box, type TextBox2. Click OK.
  2. Insert a Microsoft Forms 2.0 CommandButton by doing the following:
    1. On the Insert menu, point to Advanced, and then click ActiveX Control.
    2. In the Select A Control list, click Microsoft Forms 2.0 CommandButton.
    3. Click OK.
    4. Right-click the ActiveX Control and then click ActiveX Control Properties on the menu that appears.
    5. In the Name box, type CommandButton3. Click OK.
  3. On the Tools menu, point to Macro, and then click Microsoft Script Editor.
  4. On the HTML menu, point to Script Block and then click Server.
  5. Type the following between the Script tags:
              Sub CommandButton3_Click()
                 ' Text box will be filled in when you click the command
                 ' button.
                 TextBox2.Text="Hello World"
              End sub
    					

Check Box Example

  1. Insert a Microsoft Forms 2.0 CheckBox Control:
    1. On the Insert menu, point to Advanced, and then click ActiveX Control.
    2. In the Select A Control list, click Microsoft Forms 2.0 CheckBox. Click OK.
    3. Right-click the ActiveX Control and then click ActiveX Control Properties on the menu that appears.
    4. In the Name box, type CheckBox1.
    5. Click OK.
  2. To insert a Microsoft Forms 2.0 command button, follow these steps:
    1. On the Insert menu, point to Advanced, and click ActiveX Control.
    2. In the Select A Control list, click to select Microsoft Forms 2.0 CommandButton.
    3. Click OK.
    4. Right-click the ActiveX Control, and then click ActiveX Control Properties on the menu that appears.
    5. In the Name box, type CommandButton4. Click OK.
  3. To insert a Microsoft Forms 2.0 Label, follow these steps:
    1. On the Insert menu, point to Advanced, and click ActiveX Control.
    2. In the Select A Control list, click Microsoft Forms 2.0 Label. Click OK.
    3. Right-click the ActiveX Control, and then click ActiveX Control Properties.
    4. In the Name box, type Label2.
    5. In the Width box, type 300.
    6. Click OK.
  4. On the Tools menu, point to Macro, and select Microsoft Script Editor.
  5. On the HTML menu, point to Script Block, and click Server.
  6. Type the following code between the Script tags:
             sub CommandButton4_Click()
                ' Evaluates the value of the check box and inserts text
                ' in the label when you click the command button.
               if CheckBox1.Value=TRUE then Label2.Caption="The checkbox _
                 is checked"
               if CheckBox1.Value=FALSE then Label2.Caption="The checkbox _
                 is not checked"
             end sub
    					

Option Button Example

  1. To insert a Microsoft Forms 2.0 option button, follow these steps:
    1. In the Insert menu, point to Advanced, and click ActiveX Control.
    2. In the Select A Control list, click Microsoft Forms 2.0 OptionButton. Click OK.
    3. Right-click the ActiveX Control, and then click ActiveX Control Properties.
    4. In the Name box, type OptionButton1.
    5. Click OK.
  2. To insert a Microsoft Forms 2.0 command button, follow these steps:
    1. On the Insert menu, point to Advanced, and then click ActiveX Control.
    2. In the Select A Control list, select Microsoft Forms 2.0 CommandButton. Click OK.
    3. Right-click the ActiveX Control, and then click ActiveX Control Properties on the menu that appears.
    4. In the Name box, type CommandButton5.
    5. Click OK.
  3. To insert a Microsoft Forms 2.0 label, follow these steps:
    1. On the Insert menu, point to Advanced, and then click ActiveX Control.
    2. In the Select A Control list, click Microsoft Forms 2.0 Label.
    3. Right-click the ActiveX Control, and then click ActiveX Control Properties on the menu that appears.
    4. In the Name box, type Label3.
    5. In the Width box, type 300.
    6. Click OK.
  4. On the Tools menu, point to Macro, and then click Microsoft Script Editor.
  5. On the HTML menu, point to Script Block, and then click Server.
  6. Type the following code between the Script tags:
              Sub CommandButton5_Click()
                 ' Evaluates the value of the option button and inserts
                 ' text in the label when you click the command button.
                 If OptionButton1.Value=True Then
                 Label3.Caption = "This option is selected"
                 Else
                 Label3.Caption = "The other option is selected"
                 End If
              End sub
    					

Toggle Button Example

  1. To insert a Microsoft Forms 2.0 toggle button, follow these steps:
    1. On the Insert menu, point to Advanced, and then click ActiveX Control.
    2. In the Select A Control list, click Microsoft Forms 2.0 ToggleButton. Click OK.
    3. Right-click the ActiveX Control, and then click ActiveX Control Properties on the menu that appears.
    4. In the Name box, type ToggleButton1.
    5. In the Width box, type 100.
    6. In the Height box, type 30.
    7. Click OK.
  2. On the Tools menu, point to Macro, and then click Microsoft Script Editor.
  3. On the HTML menu, point to Script Block, and then click Server.
  4. Type the following code between the Script tags:
              sub ToggleButton1_Click()
                ' Evaluates the value of the toggle button and inserts text
                ' in the label when you click the command button.
                If ToggleButton1.Value = True Then
                ToggleButton1.Caption = "DEPRESSED"
                Else
                ToggleButton1.Caption = ""
                End If
              End Sub
    					

Spin Button Example

  1. To insert a Microsoft Forms 2.0 spin button, follow these steps:
    1. On the Insert menu, point to Advanced, and then click ActiveX Control.
    2. In the Select A Control list, click Microsoft Forms 2.0 SpinButton. Click OK.
    3. Right-click the ActiveX Control, and then click ActiveX Control Properties on the menu that appears.
    4. In the Name box, type SpinButton1.
    5. Click the Parameter tab and do the following:
      1. In the Attribute name list, click Min, and then click Modify.
      2. In the Data box, type -100.
      3. Click OK.
    6. In the ActiveX Control Properties dialog box, click Apply, and then click OK.
  2. To insert a Microsoft Forms 2.0 label, follow these steps:
    1. On the Insert menu, point to Advanced, and then click ActiveX Control.
    2. In the Select A Control list, click Microsoft Forms 2.0 Label.

      Click OK.
    3. Right-click the ActiveX Control, and then click ActiveX Control Properties on the menu that appears.
    4. In the Name box, type Label4.
    5. Click OK.
  3. On the Tools menu, point to Macro, and then click Microsoft Script Editor.
  4. On the HTML menu, point to Script Block, and then click Server.
  5. Type the following code between the Script tags:
              sub SpinButton1_SpinDown()
                 ' Evaluates if the spin button has been clicked and
                 ' inserts text in the label when you click the
                 ' command button.
                 Label4.Caption = SpinButton1.Value
              end sub
    
              sub SpinButton1_SpinUp()
                 ' Evaluates if the spin button has not been clicked
                 ' and inserts text in the label when you click the
                 ' command button.
                 Label4.Caption = SpinButton1.Value
              end sub
    
    					

Scroll Bar Example

  1. To insert a Microsoft Forms 2.0 scroll bar, follow these steps:
    1. On the Insert menu, point to Advanced, and then click ActiveX Control.
    2. In the Select A Control list, select Microsoft Forms 2.0 ScrollBar. Click OK.
    3. Right-click the ActiveX Control, and then click ActiveX Control Properties on the menu that appears.
    4. In the Name box, type ScrollBar1.
    5. Click the Parameters tab. In the Attribute window, follow these steps:
      1. Select Min and then click Modify.
      2. In the Value box, type -32766.
      3. Click OK.
    6. Click Apply and then click OK.
  2. To insert a Microsoft Forms 2.0 label, follow these steps:
    1. On the Insert menu, point to Advanced, and click ActiveX Control.
    2. In the Select A Control list, select Microsoft Forms 2.0 Label. Click OK.
    3. Right-click the ActiveX Control, and then click ActiveX Control Properties on the menu that appears.
    4. In the Name box, type Label5.
    5. Click OK.
  3. On the Tools menu, point to Macro, and then click Microsoft Script Editor.
  4. On the HTML menu, point to Script Block, and select Server.
  5. Type the following code between the Script tags:
              Sub ScrollBar_Change()
              ' Evaluates the position of the marker on the scroll bar and
              ' inserts text in the label when the command button is
              ' clicked.
              Label5.Caption = -(ScrollBar1.Value)
              End sub
    					

Combo Box Example

  1. On the Insert menu, point to Advanced, and then click ActiveX Control.
    1. On the Insert menu, point to Advanced, and then click ActiveX Control.
    2. In the Select A Control list, select Microsoft Forms 2.0 ComboBox. Click OK.
    3. Right-click the ActiveX Control, and then click ActiveX Control Properties on the menu that appears.
    4. In the Name box, type ComboBox1.
    5. Click OK.
  2. To insert a Microsoft Forms 2.0 label, follow these steps:
    1. On the Insert menu, point to Advanced, and then click ActiveX Control.
    2. In the Select A Control list, select Microsoft Forms 2.0 Label. Click OK.
    3. Right-click the ActiveX Control, and then click ActiveX Control Properties on the menu that appears.
    4. In the Name box, type Label7.
    5. In the Width box, type 400.
    6. Click OK.
  3. On the Tools menu, point to Macro, and then click Microsoft Script Editor.
  4. On the HTML menu, point to Script Block, and then click Server.
  5. Type the following code between the Script tags:
              sub ComboBox1_Click()
                 ' Evaluates which option in a combo box has been
                 ' selected and fills in the resulting text in the label
                 ' when the command button is clicked
                 Label7.Caption= "You have selected " & _
                 ComboBox1.List(ComboBox1.ListIndex)
              end sub
    						
    NOTE: A ComboBox requires you to write script that populates the list with values in an array. The script should be inserted at the top of the page so that it runs when your page is opened in a Web browser.
  6. To insert the script to populate the Microsoft Forms 2.0 combo box, follow these steps:
    1. On the Tools menu, point to Macro, and select Microsoft Script Editor.
    2. On the HTML menu, point to Script Block, and then click Server.
    3. Type the following code between the Script tags.

      NOTE: Place this code at the bottom of the Script box, after the existing script, but before the last line that reads "end sub."
              ' Creates and populates the array used in the
              ' preceding list box example.
              '
              ' Dimension array to populate the list box.
              Dim ListBoxArray(2)
              ListBoxArray(0)="RED"
              ListBoxArray(1)="WHITE"
              ListBoxArray(2)="BLUE"
              ListBox1.List=ListBoxArray
    					



↑ Back to the top


References

Warning The Microsoft Forms 2.0 package was not designed to work outside of the Visual Basic for Applications environment. While individual developers might be successful in deploying it to containers such as Microsoft Internet Explorer, using Forms in this manner is neither recommended nor supported. For more information, see the following Microsoft Knowledge Base article:
236458� PRB: Using Microsoft Forms 2.0 in Internet Explorer


↑ Back to the top


Keywords: KB208272, kbhowtomaster, kbscript, kbprogramming, kbactivex, kbforms

↑ Back to the top

Article Info
Article ID : 208272
Revision : 3
Created on : 8/15/2006
Published on : 8/15/2006
Exists online : False
Views : 336