Controls Collection: Order of Controls

R

ronymaxwell

I have a large number of image controls in a Word document which ar
initially set to be hidden to the user (Controlname.Visible = False).
According to actions the user takes images become visible. The code fo
referencing these images relies on the Controls Collectio
(Application.ActiveDocument.Shapes(1).CanvasItems(i) where i is
particular image). I want to add a couple of images to the document
but I don't want them to be placed at the end of the controls collectio
as the For..next loop I use to reference them relies on their being in
particular position relative to the others. I need to change the orde
of the controls in the collection so that I can have the new inage
where I want them. The alternative is to laboriously change the image
to get the new ones in the places I need them. Is it possible t
change the order of the controls collection
 
S

Stefan Blom

You can't control the index numbers for members of a collection. Sometimes, the
largest reference number corresponds to the last collection member, but I
wouldn't rely on it...

Some objects can be named; I my experience, using the name is the safest way to
reference it in a collection.

For more on this, you may want to ask in the MSDN Word Developer forum; see
http://social.msdn.microsoft.com/Forums/en-US/worddev/threads.

--
Stefan Blom
Microsoft Word MVP



"ronymaxwell" wrote in message
I have a large number of image controls in a Word document which are
initially set to be hidden to the user (Controlname.Visible = False).
According to actions the user takes images become visible. The code for
referencing these images relies on the Controls Collection
(Application.ActiveDocument.Shapes(1).CanvasItems(i) where i is a
particular image). I want to add a couple of images to the document,
but I don't want them to be placed at the end of the controls collection
as the For..next loop I use to reference them relies on their being in a
particular position relative to the others. I need to change the order
of the controls in the collection so that I can have the new inages
where I want them. The alternative is to laboriously change the images
to get the new ones in the places I need them. Is it possible to
change the order of the controls collection?
 

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