[resolved] changing a controls propertry - WORD
Hi all,
I have such a problem:
How can I change a controls properties, while referring to the control's name
using a variable??? I have 50 labels named: label1, label2, label3,...,label50. And I would like programmatically change properties of all this labels using loop???
Controls are embedded in document NOT in the form.
I am using Word 2003.
Please help.
Regards,
sweet_dreams
Re: changing a controls propertry - WORD
This will work for the ActiveX controls.
VB Code:
ThisDocument.TextBox1.Text = "Test"
Re: changing a controls propertry - WORD
Thx RobDog888
But what should I do to be able to change for examlple 100 such a controls. I would like to use loop to change it's properties at the same time. So how can refer to controls property for eg.
VB Code:
for i=1 to 100
text&i.text="hello" & I
next i
I know that above code looks ridiculous but I would like to do sth like that.
Please help,
sweet_dreams
Re: changing a controls propertry - WORD
]For Each ctl in ThisDocument.InlinShapes
VB Code:
Dim ctl As InlineShape
For Each ctl In ThisDocument.InlineShapes
ctl.OLEFormat.Object.Text = "Test"
Next
Re: changing a controls propertry - WORD
VB Code:
Dim i as integer
For i = 1 to Thisdocument.inlineshapes.count
ThisDocument.InlineShapes(i).OLEFormat.Object.Text = "Test " & i
Next
:)
Re: changing a controls propertry - WORD
Thx once again RobDog888, it works fine.
But do you know is it possible to change properties of only particular control for eg. Label ??? Because I have not only labels but also other controls.
Re: changing a controls propertry - WORD
Yes, you would have to "filter" out to just the type of control you want to edit or by its control name.
VB Code:
ThisDocument.InlineShapes(i).Type =wdInlineShapeOLEControlObject
ThisDocument.InlineShapes(i).OLEFormat.Object.Name
Re: changing a controls propertry - WORD