Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting the next OLEformat.object in Word

Status
Not open for further replies.

nochoice

Programmer
Jun 17, 2003
72
CA
Good Afternoon - depends on when you read this,

I have a document with 100 checkboxes and beside each checkbox is a combobox,

If I currently have selected a checkbox, how can I select the adjacent combobox?.....It's a little more complicated than wdExtend I think; here is my code:

'searches document for all inlineshapes
For Each ml in ActiveDocument.InlineShapes

'if the left 2 characters of the object is gr, check it's value, if it's value is true (i.e. checked) continue
If Left(ml.OLEFormat.object.name, 2) = "gr" Then
If ml.OLEFormat.object.value = True Then

'searches document for all inlineshapes beginning with aa and adds the caption of the checkbox to the combobox
For Each sh In ActiveDocument.InlineShapes
If sh.Type = 5 Then
If Left(sh.OLEFormat.Object.Name, 2) = "aa" Then
NEXTCOMBOBOX.AddItem sh.OLEFormat.Object.Caption
End If
End If
Next

End If
End If

Next


I hope everything made sense.

Thanks In Advance,
NoChoice
 
I solved it, poorly, but it works.

If anybody has a 'Cleaner' solution, I'd appreciate it.

Here is the revised code:

For Each ml In ActiveDocument.InlineShapes

If Left(ml.OLEFormat.Object.Name, 2) = "gr" And ml.OLEFormat.Object.Value = True Then
mark.Value = "1"
ElseIf mark.Value = "1" Then
mark.Value = "0"

For Each sh In ActiveDocument.InlineShapes
If sh.Type = 5 Then
If Left(sh.OLEFormat.Object.Name, 2) = "aa" Then
If sh.OLEFormat.Object.Value = True Then
ml.OLEFormat.Object.AddItem sh.OLEFormat.Object.Caption
End If
End If
End If
Next

End If

Next


I hope you can understand this

Cheers,
NoChoice
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top