use control in word by name
Hi,
I am trying to assign some values to some activex textboxes in a word 2007 document.
i have named the textboxes like txt1,txt2,txt3,txt4,...
Now i m wondering if there is something like this possible:
for i = 1 to 4
getControlByName("txt" & i).text = "test " & i
next
Thanks in advance
Re: use control in word by name
You might have to go the route of:
Code:
For i - 1 to 4
tmpVal = "txt" & i
getControlByName(tmpVal).text = "test" & i
Next i
Re: use control in word by name
Hi fizii,
Thanks for the quick reply.
I 've been trying that already and i know it works fine in .NET but in office VBA it gives me "Sub or Function not defined".
So i was wondering if there is an alternative for this?
Re: use control in word by name
you can try like
vb Code:
For i = 1 To 3
activedocument.Shapes("Text box " & i).TextFrame.TextRange = "test " & i
Next
assuming your textboxes are named as default
text box 1
text box 2
etc
or with your existing texboxes
activedocument.Shapes("txt" & i).TextFrame.TextRange = "test " & i
and change to whatever document object you want to use