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 / January 2007

Tip: Looking for answers? Try searching our database.

Subscript Out of range error when refering to named Shape

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Cory - 29 Jan 2007 22:03 GMT
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
Cory - 30 Jan 2007 04:02 GMT
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

> I am experimenting in Publisher 2007.  I created a Textbox Shape
> programmatically and named it "MyText".  I then Inserted a new page (via the
[quoted text clipped - 17 lines]
>
> Cory
 
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.