Displaying the label of the selected Option Button

J

Jeff Parker

Hi, in Word 2003, how can I display elesewhere in the doc the label
associated with the radio/option button that the user has selected? Has this
something to do with Fields? I can't seem to work out how to do it. Any
thoughts please?
 
G

Graham Mayor

Can I suggest that you don't use activex controls in a document. They are
primarily intended for web page creation. Use instead check boxes - which
can emulate the action of radio buttons with the aid of macros. -
http://word.mvps.org/faqs/tblsfldsfms/ExclusiveFmFldChbxs.htm

However to answer the question asked, radio buttons work in groups. In the
case of two radio buttons with default names you can display that name with
a docvariable field - here {Docvariable varBtn} - and you can set the value
of that variable by using the macro code associated with the option button
eg

Option Explicit
Private oVars As Variables
Private Sub OptionButton1_Click()
Set oVars = ActiveDocument.Variables
If OptionButton1.Value = True Then
oVars("varBtn").Value = "OptionButton1 selected"
End If
ActiveDocument.Fields.Update
End Sub
Private Sub OptionButton2_Click()
Set oVars = ActiveDocument.Variables
If OptionButton2.Value = True Then
oVars("varBtn").Value = "OptionButton2 selected"
End If
ActiveDocument.Fields.Update
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top