Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word Loop thru userforms.

Status
Not open for further replies.

hermanlaksko

Programmer
Aug 26, 2001
938
DK
Is there a way to loop thru the forms in word?.
It should be simple ie.
For I = 0 To Doc.Forms.Count
code
Next

However Forms can not be fnd under ThosDocument ... or anywhere else.... smile
Can anyone help?
Thanks

Herman
Say no to macros
 
Not so easy if you mean userform as a part of vbproject.
You need a reference to VBIDE library (Microsoft Visual Basic for Applications Extensibility). The collection: Doc.VBProject.VBComponents. VBProject is common (Word and VBIDE), VBComponents is a part of VBIDE. You need to test Type property, for userform vbext_ct_MSForm = 3.
You test VB IDE components, that are different from active (open) userforms. Due to security, you need programmatic access to VBA project.


combo
 
Hi Combo
Thank you for your answer, I will try that.
If you have any code in stock
I would love to see it 😀


Herman
Say no to macros
 
>You need a reference to VBIDE library

You don't, you know (well, ok, you do if you want a predeclared vbext_ct_MSForm - but you can declare that for yourself)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top