Greg
Thu Aug 10 20:43:40 CDT 2006
Jay,
Wow. Good detective work. I will play around with this some. Thanks. I
wonder why:
> Sub Test2()
> Dim Ct As MSForms.OptionButton
> Set Ct = Me.Pass1
> MsgBox Ct.Caption
> End Sub
Didn't throw some kind of error?
--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.
Jay Freedman wrote:
> Hi Greg,
>
> It certainly wasn't easy to find this out -- it took some spelunking
> in the Object Browser for likely bits of terms. :-b
>
> The Control Toolbox controls are members of either the InlineShapes
> collection or the Shapes collection, depending on whether they're
> inline or floating, just like pictures.
>
> For inline controls, use a loop like this:
>
> Sub foo1()
> Dim ctl As InlineShape
> For Each ctl In ActiveDocument.InlineShapes
> If ctl.Type = wdInlineShapeOLEControlObject Then
> MsgBox ctl.OLEFormat.Object.Caption
> End If
> Next
> End Sub
>
> For floating controls, use a loop like this:
>
> Sub foo2()
> Dim ctl As Shape
> For Each ctl In ActiveDocument.Shapes
> If ctl.Type = msoOLEControlObject Then
> MsgBox ctl.OLEFormat.Object.Caption
> End If
> Next
> End Sub
>
> If it's possible that both kinds are present, you have a heck of a
> mess. I guess you could loop through the Paragraphs collection looking
> for first one kind and then the other...
>
>
>> I am stumgling in the dark trying learn something to help a poster.
>>
>> I have a Word document with some controls entered in the document
>> using the Control Toolbox. Specifically I have some options buttons
>> named Pass1 through Pass4.
>> I can run Sub Test1() to return the caption of Pass1. I can further
>> specifically (and I don't know if it is right or not) declare the
>> variable as a MSForms.OptionsButton and get the result using Sub
>> Test2(). What I can't figure out is how to cycle through each
>> control in the document and determine the caption.
>>
>> It seems that there is no:
>>
>> For each Ct in Me.Controls or Me.MSForms.OptionButtons or
>> Me.Anything that will work.
>>
>> Can anyone help or confirm the quest is hopeless. Thanks.
>>
>> Sub Test1()
>> Dim Ct
>> Set Ct = Me.Pass1
>> MsgBox Ct.Caption
>> End Sub
>>
>> Sub Test2()
>> Dim Ct As MSForms.OptionButton
>> Set Ct = Me.Pass1
>> MsgBox Ct.Caption
>> End Sub
>>
>> Sub Test3()
>> Dim Ct As MSForms.OptionButton
>> For Each Ct In Me (what would go here to get name of each
>> OptionButton in the form).
>> MsgBox Ct.Caption
>> Next
>> End Sub