Using Arrays for grouping shapes

C

Cory

I am using a dynamic array with a variable number of elements to describe
several shapes on a page. When I go to group the shapes using

(Some variable references omitted for space)

CurrentPage.Shapes.Range(Index:=ShapeArray()).Group

it gives me a "SubScript out of range" error. After adding a watch and
several breaks concerning the Array, it is adding the shape names correctly.
All elements are filled and none are missing. Am I referencing the array
incorrectly or what? The only examples I have seen have things like
..Shapes.Range(Index:=Array("Shape1", "Shape2", "Shape3").Group

But I do not know at design time how many shapes there will be or what their
names will be. I am using Publisher 2002. Any help will be appreciated.
 
E

Ed Bennett

Cory said:
I am using a dynamic array with a variable number of elements to describe
several shapes on a page. When I go to group the shapes using

(Some variable references omitted for space)

CurrentPage.Shapes.Range(Index:=ShapeArray()).Group

Is ShapeArray() an array of Publisher.Shape objects?
it gives me a "SubScript out of range" error. After adding a watch and
several breaks concerning the Array, it is adding the shape names correctly.
All elements are filled and none are missing. Am I referencing the array
incorrectly or what? The only examples I have seen have things like
.Shapes.Range(Index:=Array("Shape1", "Shape2", "Shape3").Group

Sadly a lot of the code examples do this; they're rarely relevant.
 
C

Cory

I figured it out:
I Dim-ed ShapeArray() originally as String for whatever reason. I was
putting strings into it, but it would not pass those to the Range method in a
way that it would understand them and build the range. I went back and
changed it to Variant and it works. The extra runtime (because the system
has to assign a data type) is so negligible that it is unnoticed, so it is
alright. I can assume that it should have been Array or something?

Cory
 

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

Similar Threads


Top