Reset ActiveX Radio Control buttons

G

Greg Maxey

I have some ActiveX radio buttons in a protected word document. I want to set all of the buttons initially to false. Here is the code that I scratched together:

Sub ResetRadioButtons()
Dim oILS As InlineShape
For Each oILS In ActiveDocument.InlineShapes
If oILS.Type = wdInlineShapeOLEControlObject Then
oILS.OLEFormat.Object.Value = False
End If
Next
End Sub

It works, but I was wondering if it this is a good way of doing this. Thanks.
 
C

Cindy M.

Hi Greg,
I have some ActiveX radio buttons in a protected word
document. I want to set all of the buttons initially to
false. Here is the code that I scratched together: Sub
ResetRadioButtons()
Dim oILS As InlineShape
For Each oILS In ActiveDocument.InlineShapes
If oILS.Type = wdInlineShapeOLEControlObject Then
oILS.OLEFormat.Object.Value = False
End If
Next
End Sub It works, but I was wondering if it this is a
good way of doing this.
You could run into problems if the document contains a
control that can't be set to false, or contains controls
that you don't want set to false (text box, for example).
So you might want to check, in addition, the OLEFormat's
ClassType.

But I do think this is the only approach you can use, yes.

If it's something you need to do more than once during the
lifetime of your code it would probably make sense to
perform the loop only once, adding the object to an array
or a collection.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update
Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:)
 
G

Greg Maxey

Cindy,

Thanks. Tony Jolans set me on this course which seems to work just fine:

Sub ResetRadioButtons()
Dim oILS As InlineShape
Dim oCntr As Object
For Each oILS In ActiveDocument.InlineShapes
If oILS.Type = wdInlineShapeOLEControlObject Then
If TypeOf oILS.OLEFormat.Object Is MSForms.OptionButton Then
oILS.OLEFormat.Object.Value = False
End If
End If
Next
End Sub
 

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