Subscript Out of range error when refering to named Shape

C

Cory

I am experimenting in Publisher 2007. I created a Textbox Shape
programmatically and named it "MyText". I then Inserted a new page (via the
GUI and duplicated everything on the first page (MyText was the only thing
there). Using another macro I checked that the text box on Page 2 is in fact
named MyText.

The statements :
Dim vNewText as String
vNewText = "Newer Text"
ActiveDocument.Pages(1).Shapes("MyText").TextFrame _
.TextRange.Text = vNewText

change the text in the text box on Page 1 however, when changing Pages(1) to
Pages(2) (In effect referring to an identical textbox on a different page) I
Get Runtime Error '9' Suscript out of range.

The only KB articles that had anything to do with this talked about
referring to color styles that could not be referenced programmatically, and
doing so would result in the above error, but the similarities end there.

Cory
 
C

Cory

Ah So!

Undoubtedly there can only be one Shape named X per document (Unles you
duplicate page). Even though Publisher 2002 (which I use at work) is much
more compartmented in regards to pages (Can't move em, rename em) and in 2007
Shapes are further broken up by pages, it seems like you should be able to
have more than one Shape named something since you have to specify Page
first. Either way, I answered my own question. Hope it benefits someone.

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

Top