Grouping of textboxes in Word

C

CØstergaard

Does anyone know a way of grouping objects, e.g. a textbox, other than using
the name of every object in an array?
I am creating a lot of textboxes in a for-loop, so I have no idea, how many
boxes, that are created.
I am running Word 2000, VBA 6.0

My code looks kind of like this:

Dim Leaves() As Shape
(lot of code)
redim leaves(imax) as shape
for ix = 0 to imax 'imax migth be 0, so the code must be dynamic
Set Leaves(ix) = ActiveDocument.Shapes.AddTextbox(...)
Next ix

ActiveDocument.Shapes.Range(Array(Leaves(0).Name,
Leaves(1).Name,Leaves(2).Name )).Group
' This will not work, as I don't know, how many textboxes there are.


C. Østergaard
 
P

Peter Jamieson

Although the parameter for the Range method is a Variant array, you should
also be able to use an Array of Variants, e.g. something like

Dim Leaves() As Shape
Dim LeafArray() As Variant
(lot of code)
redim leaves(imax) as shape
redim LeafArray(imax) As Variant
for ix = 0 to imax 'imax migth be 0, so the code must be dynamic
Set Leaves(ix) = ActiveDocument.Shapes.AddTextbox(...)
Next ix

ActiveDocument.Shapes.Range(LeafArray).Group

Peter Jamieson
 
C

CØstergaard

Thanks for the help, it worked


Peter Jamieson said:
Although the parameter for the Range method is a Variant array, you should
also be able to use an Array of Variants, e.g. something like

Dim Leaves() As Shape
Dim LeafArray() As Variant
(lot of code)
redim leaves(imax) as shape
redim LeafArray(imax) As Variant
for ix = 0 to imax 'imax migth be 0, so the code must be dynamic
Set Leaves(ix) = ActiveDocument.Shapes.AddTextbox(...)
Next ix

ActiveDocument.Shapes.Range(LeafArray).Group

Peter Jamieson
 

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