Hi =?Utf-8?B?YmFyYg==?=,
First of all thank you for responding. I am usinf word 2007 and I need to
right in vb an if statement indicating that if a true is checked add one and
if a false is checked do not add anything but zero, in a box that give the
total at the end.
I have from the developmeer tab selected tools and indicated that I was a
option box for a dot 1 for true and 1 for false.
This last sentence isn't making any sense; I'm assuming you mean "0 for false"?
Here's a code sample that loops through all the InlineShapes in a document,
checks whether it's a MSForms control and, if it is, whether the name starts
with "opt". I don't think there's any way to determine whether an ActiveX
control is one kind or another, except through using a naming convention. If the
control meets all the criteria its value is checked and the running sum adjusted
accordingly:
Sub CalculateActiveXOptionButtons()
Dim lSum As Long
Dim doc As Word.Document
Dim shp As Word.InlineShape
Dim ctl As Variant 'MsForms.OptionButton
Set doc = ActiveDocument
For Each shp In doc.InlineShapes
If shp.Type = wdInlineShapeOLEControlObject Then
Set ctl = shp.OLEFormat.Object
If Left(ctl.Name, 3) = "Opt" Then
If ctl.Value <> 0 Then
lSum = lSum + 1
End If
End If
End If
Next
MsgBox "The sum of option buttons checked = " & CStr(lSum)
End Sub
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