Accessing controls on word document (not userform)

S

SS

Hello all,

I have multiple text boxes (Text Box selection from the Control Toolbox) in
a word document. Most of the books I have read talks about how to work with
controls on a userform but not with controls on the application itself
(Microsoft Word).

The code below is for accessing text boxes in a userform. How can I achieve
the same thing if all my text boxes were on a Microsoft Word document?

When I type in Debug.Print(ThisDocument.controls.count) it doesn't recognize
the text boxes I have on the document.

Please help. Thanks in advance.
SS

Dim ctrl as MSForms.Control
For Each ctlr in Me.Controls
If TypeOf ctrl is MSForms.TextBox Then
' reset if the current control is a textbox:
ctrl.value = ""
End If
Next
 
C

Cindy M -WordMVP-

Hi Ss,
I have multiple text boxes (Text Box selection from the Control Toolbox) in
a word document. Most of the books I have read talks about how to work with
controls on a userform but not with controls on the application itself
(Microsoft Word).
I wrote an article on this a couple of years ago. Search my name on the msdn
website.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top