Registrations are now open. Join us today!
There is still a lot of work to do on the wiki yet! More information about editing can be found here.
Already have an account?

Microsoft KB Archive/168851

From BetaArchive Wiki

Article ID: 168851

Article Last Modified on 6/12/2007



APPLIES TO

  • Microsoft Word 97 Standard Edition



This article was previously published under Q168851

SYMPTOMS

When you group a series of ActiveX option buttons on a Microsoft Word document by setting the group name for each ActiveX option button to the same name, changing the value of one ActiveX option button within the group to TRUE does not toggle the values of the other ActiveX option buttons within the same group to FALSE.

CAUSE

By Design, ActiveX option buttons, when inserted from the Control Toolbox, are inserted as floating objects. Option buttons inserted as floating objects are not mutually exclusive, even when their GroupName property is identical.

WORKAROUND

To work around this problem, use one of the following methods.

Method 1: Convert the ActiveX Option Buttons to Inline Objects

Converting the ActiveX option buttons to inline objects will allow you to toggle the values of grouped option buttons.

To convert the ActiveX option buttons to inline objects:

  1. If the Control Toolbox is not visible, on the View menu, point to Toolbars, and click Control Toolbox.
  2. On the Control Toolbox, click Design Mode.
  3. Select an option button to convert to inline.
  4. Right-click the option button to display the option button shortcut menu.
  5. On the option button shortcut menu, point to OptionButton Object and click Convert.
  6. On the Convert dialog box, clear the Float Over Text check box.
  7. Click OK.
  8. Repeat steps 3-7 for each option button you want to group.

To group the option buttons:

  1. Select an option button to group.
  2. On the Control Toolbox, click Properties.
  3. In the GroupName property text box, type a unique group name for each option button within the same grouping. For example, if you inserted four option buttons in a document and you want to have two separate groups consisting of

    Group1: Option Buttons 1 and 2
    Group2: Option Buttons 3 and 4

    Type "Group1" (without the quotation marks), as the GroupName value for option buttons 1 and 2.

    Type "Group2" (without the quotation marks) as the GroupName value for option buttons 3 and 4.
  4. Repeat steps 1-3 for each option button within similar groupings.

NOTE: To allow the text to wrap around the option buttons, place them in a frame (do not use a text box).

For additional information about using Frames, please see the following article in the Microsoft Knowledge Base:

Q159942 WD97: General Information about Text Boxes and Frames in Word 97


Method 2: Use the Following Macro Examples to Toggle the Values



Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals 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 needs. If you have limited programming experience, you may want to contact a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please visit the following Microsoft Web site:

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:

The following sample Visual Basic for Applications macro will allow you to keep the option button float over text status and toggle the values based on groupings.

Before running the macro examples, group the option buttons as detailed in the steps "To group the option buttons" described earlier in this article.

Place the following procedure in the General Declarations section of the Normal project.

   Public Sub SetOptionGroupValues(sName As Object)

      Dim sGroup As String
      Dim oShape As Shapes
      Set oShape = ActiveDocument.Shapes
      For i = 1 To oShape.Count
         ' If the Shape is an Option Button.
         If oShape(i).OLEFormat.ClassType = "Forms.OptionButton.1" Then
            ' If the Option Button in the collection
            ' is NOT the selected option button.
            If oShape(i).OLEFormat.Object.name <> sName.name Then
               ' If the option button is in the defined group.
               If oShape(i).OLEFormat.Object.GroupName = _
               sName.GroupName Then
                  ' Make it's value false.
                  oShape(i).OLEFormat.Object.Value = False
               End If
            End If
         End If
      Next

   End Sub
                



For each option button in your group, place the following example code that calls the SetOptionGroupValues sub-routine within each option button's GotFocus event procedure.

SetOptionGroupValues <OptionButtonName>
                

The argument, <OptionButtonName> must match the name of the option button.

For example,

   Private Sub OptionButton1_GotFocus()
      SetOptionGroupValues OptionButton1
   End Sub

   Private Sub OptionButton2_GotFocus()
      SetOptionGroupValues OptionButton2
   End Sub
                



To view the GotFocus event procedure for an option button:

  1. In design mode, double-click an option button.
  2. In the Visual Basic for Applications Editor Code window, select GotFocus from the Procedures box.



Additional query words: wordcon word97 word8 8.0 vb vbe vba

Keywords: kbcode kbhowto kbmacro kbmacroexample kbprogramming KB168851