I tried applying your code to what I have. My version appears logically the
same as yours, but it has no effect. The following is just a little
simplified, showing only one of my option groups. If you can point out any
errors you see, I'd appreciate it.
Notes:
- This userform already works correctly, and it even leaves the user's
choices showing in the option groups, but they're gone when I re-open the
document.
- The DocVariable shown here uses string values for true and false.
In the userform code:
----------------
' Defining the group:
Private Sub UserForm_Initialize()
YesOption.GroupName = "InclTitle"
NoOption.GroupName = "InclTitle"
End Sub
-----------------
' "Yes" button:
Private Sub YesOption_Click()
ActiveDocument.Variables("include-title").Value = "True"
End Sub
-----------------
' "No" button:
Private Sub NoOption_Click()
ActiveDocument.Variables("include-title").Value = "False"
End Sub
--------------------------------------
' Part of the routine that calls the userform.
' Read include-title option, which might not be set yet:
On Error Resume Next
sTitleOption = ActiveDocument.Variables("include-title").Value
If Err.Number <> 0 Then ' If it's not set, set it to "True" string
value
ActiveDocument.Variables("include-title").Value = "True"
sTitleOption = "True"
End If
Select Case sTitleOption
Case "True"
YesOption.Value = True
NoOption.Value = False
Case "False"
YesOption.Value = False
NoOption.Value = True
End Select
Private Sub OptionButton1_Click()
If OptionButton1.Value = True Then ActiveDocument.Variables("Test") = 1
End Sub
Private Sub OptionButton2_Click()
If OptionButton1.Value = True Then ActiveDocument.Variables("Test") = 2
End Sub
Private Sub OptionButton3_Click()
If OptionButton1.Value = True Then ActiveDocument.Variables("Test") = 3
End Sub
Then, in the routine the running of which you want to set the Option
button
according to the value of the document variable, use
Select Case ActiveDocument.Variables("Test").Value
Case 1
OptionButton1.Value = True
OptionButton2.Value = False
OptionButton3.Value = Flase
Case 2
OptionButton1.Value = False
OptionButton2.Value = True
OptionButton3.Value = Flase
Case 3
OptionButton1.Value = False
OptionButton2.Value = False
OptionButton3.Value = True
End Select
I have some option groups on a form. A group sets a DocVariable value,
and
I
[quoted text clipped - 5 lines]
to
do it. Would appreciate suggestions or links.