Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Publisher / Programming / May 2007

Tip: Looking for answers? Try searching our database.

Using Arrays for grouping shapes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Cory - 22 May 2007 14:43 GMT
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.
Ed Bennett - 23 May 2007 00:05 GMT
> 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.

Signature

Ed Bennett - MVP Microsoft Publisher
http://ed.mvps.org

Cory - 23 May 2007 18:17 GMT
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

> > 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
[quoted text clipped - 12 lines]
>
> Sadly a lot of the code examples do this; they're rarely relevant.

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.