WD97: Grouped Floating Option Buttons Not Mutually ExclusiveLast reviewed: August 27, 1997Article ID: Q168851 |
The information in this article applies to:
SYMPTOMSWhen 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.
CAUSEBy 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.
WORKAROUNDTo work around this problem, use one of the following methods.
Method 1: Convert the ActiveX Option Buttons to Inline ObjectsConverting 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:
Method 2: Use the Following Macro Examples to Toggle the ValuesMicrosoft provides examples of Visual Basic for Applications procedures 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. The Visual Basic procedures in this article are provided 'as is' and Microsoft does not guarantee that they can be used in all situations. While Microsoft support engineers can help explain the functionality of a particular macro, they will not modify these examples to provide added functionality, nor will they help you construct macros to meet your specific needs. If you have limited programming experience, you may want to consult one of the Microsoft Solution Providers. Solution Providers offer a wide range of fee-based services, including creating custom macros. For more information about Microsoft Solution Providers, call Microsoft Customer Information Service at (800) 426-9400. 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 SubFor 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 SubTo view the GotFocus event procedure for an option button:
|
Additional query words: word97 word8 8.0 8.0 vb vbe vba
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |