Dave said:
I'm trying to figure out how to address radio buttons, optionbuttons,
programmatically. These controls are embedded in a document, and I'd
like to use something similar to the way you can use
me.controls("nameofwhatever") to address them on a form. Any
suggestions?
My most useful suggestion would be to give up on ActiveX controls embedded
in the body of the document, as they're more trouble than they're worth.
Create a userform instead. There, you can actually use the
Controls("nameofwhatever") syntax.
If you're stuck with ActiveX controls for some reason, the only usable
article about them is
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnword2k2/html/odc_activeX.asp.
In the ThisDocument module, you can simply address the controls by name,
such as OptionButton1 (or whatever name you assign in the Properties
dialog).
If you're going to iterate through the controls, the first thing you have to
know about your controls is whether they're inline or floating. Inline
controls are members of the ActiveDocument.InlineShapes collection, while
those that are floating are members of the ActiveDocument.Shapes collection;
they have to be dealt with separately. You must go through one of those
collections to get to the control's Name property, as in Listing 10 of the
article:
doc.Variables("PreviousControl").Value _
= doc.InlineShapes(1).OLEFormat.Object.Name
You have to know (or test) that InlineShapes(1) is an object that has an
OLEFormat property -- you can use a statement like
If doc.InlineShapes(1).Type = wdInlineShapeOLEControlObject Then
to avoid getting an error, or just use On Error Resume Next and then test
for Err.Number = 0.
--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.