troubleshooting Question

How to loop with VBA on all controls placed in a Word doc ?

Avatar of Bernard Thouin
Bernard ThouinFlag for Switzerland asked on
Microsoft Word
4 Comments1 Solution3450 ViewsLast Modified:
Hi

I'm working on a Word template with controls, which I chose from the Control Toolbox (NOT from the "Forms" toolbar). It all works well until I try, in a kind of checking routine, to loop through all controls in the document creted through the template.

I can refer, in the VBA code, to single controls in the document with "Me.<Control name>", but I can't, for the life of me, find the syntax to go through all controls (to check their contents) in a generic loop.

I've tried to loop on Fields and FormFields, but I don't get what I want. The only thing I can find out is that I have 42 "fields" (which are my controls, in fact) and their type (combobox, textbox, listbox, ..), but I am unable to find how to get the controls' name and content in a generic "For next" loop. As I can't believe that this is not possible, I'm asking you for help :-)

Bernard
ASKER CERTIFIED SOLUTION
GrahamSkan
Retired
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros