Validate Optionbutton Groups w/ loop II

M

Matt

I have a number of documents being inserted into a main document at a
certain section. Each of these inserted docs contain a varying
number of option button groups. I wish to validate these groups
through some sort of loop. If no option is chosen within a group it
will notify the user.

In a past thread, I was given the following code snipet by WordMVP,
Cindy Meister.

For each ils in ActiveDocument.InlineShapes
If ils.Type = wdInlineShapeOLEControlObject Then
Select Case ils.OleFormat.Object.GroupName
Case "Group1"
If ilsOleFormat.Object.Value = True _
Then bGroup1 = True
Case "Group2"
If ilsOleFormat.Object.Value = True _
Then bGroup2 = True
End Select
End If
Next ils
If Not bGroup1 Then MsgBox _
"You haven't selected an option from Group1"
If Not bGroup2 Then MsgBox _
"You haven't selected an option from Group2"

Here is my latest version based on the above sample:


'*******************Snippet

Sub LatestVersion()
Dim casename As String
Dim ils As InlineShape
For Each ils In ActiveDocument.InlineShapes
x = x + 1
'MsgBox x
If ils.Type = wdInlineShapeOLEControlObject Then
casename = ils.OLEFormat.Object.GroupName
Select Case casename
Case casenameLx
If ils.OLEFormat.Object.Value = True Then
casenameLx = True
End If
End Select
End If
Next ils

If Not casenameLx Then MsgBox _
"You haven't selected an option from Item" & x & "of Section A"

End Sub
'***************************************

However, for some reason I am not getting the proper results. Are
there any suggestions beyond Cindy's very helpful input?
 

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