Working with ActiveX OptionButtons as a Class

G

Greg Maxey

A month or so ago I was studying and trying to understand Classes a
little better. I have a document with several option buttons that I
want to reset all the values to false. The following code is working,
but with the On Error statements, it will throw an errror if there is a
ActiveX listbox, etc. Also ActiveX text box values are set to "False"
when I run this code:

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

I have been unable to come up with any code that will determine "IF"
the wdInlineShapeOLEControlObject is an "OptionButton" Then ...

I was thinking that since the ActiveX OptionButtons are a Class (at
least I think they are) then I should somehow be able to work with the
collection of optionbuttons in the class. I can seem to get off the
ground with this.

Any ideas? Thanks.
 
T

Tony Jollans

The Shape is just a generic object. To find out information about it you
need to look at the OLEFormat.Object object. In particular to find out its
type you can check

Typename(oILS.OLEFormat.Object)

or you can use

If typeof oils.OLEFormat.Object is MSFOrms.OptionButton then

There isn't any collection of Optionbuttons that I know about.
 
G

Greg Maxey

Tony,

Helpful as always. Thanks.

Greg
Tony said:
The Shape is just a generic object. To find out information about it you
need to look at the OLEFormat.Object object. In particular to find out its
type you can check

Typename(oILS.OLEFormat.Object)

or you can use

If typeof oils.OLEFormat.Object is MSFOrms.OptionButton then

There isn't any collection of Optionbuttons that I know about.
 
T

Tony Jollans

My pleasure Greg - sorry, I didn't notice who had posted the question, or I
would have addressed you by name :)
 

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