🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #16422

[VB] Ittarate over pageitems won't work

#16422
From: Eelko Heuvelmans
Date: Fri, 12 Sep 2003 09:59
30 lines
2080 bytes
Hi all.

I'm stuck. I'm looking in my page for a frame called "Header" (it's label is header). Now i have this bit of code:


Dim myDocument As InDesign.Document
Dim myPage As InDesign.Page
Dim myPageItem As InDesign.PageItem

myDocument = InDesignInstance.ActiveDocument 'assign active document
myPage = myDocument.Pages.Item(1) 'get first page (just to test)

For i As Integer = 1 To myPage.AllPageItems.Count 'loop trough all pageitems
   myPageItem = myPage.AllPageItems.Item(i) 'referenxe to pageitem (trouble line!!)
   MessageBox.Show("Test for label: " + mypageItem.Label.ToString) 'display label
Next 'next item...


Now, the problem :)
if i leave out this line:
myPageItem = myPage.AllPageItems.Item(i) 'referenxe to pageitem (trouble line!!)
My script runs (note to edit the messagebox) and displays a messagebox for each pageitem.
But is i want it's label i get an error, this one: " Specified cast is not valid." so i cant do myPageItem = mypage.allpageitems.item(i)

What is going wrong? I'm sure it must be simple as a brick ):-S but at the moment i don't see it. Someone a hint?

Thanks in advance!
Eelko Heuvelmans -script newbe :)-

ps: i use ID2.0.2 and i script with VB.Net, on w2k
Technical Details
Message-ID: <2ccd6887.-1@webx.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-09!supernews.com!diablo.theplanet.net!kibo.news.demon.net!demon!news2.euro.net!newsgate.cistron.nl!news.tele.dk!news.tele.dk!small.news.tele.dk!lnewsoutpeer00.lnd.ops.eu.uu.net!lnewsinpeer01.lnd.ops.eu.uu.net!emea.uu.net!newsfeed01.sul.t-online.de!t-online.de!webx

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,434b6b988840c727,start
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-09-12 03:08:03 PST
From: "Eelko Heuvelmans" <eelko.heuvelmans@planet.nl>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-09!supernews.com!diablo.theplanet.net!kibo.news.demon.net!demon!news2.euro.net!newsgate.cistron.nl!news.tele.dk!news.tele.dk!small.news.tele.dk!lnewsoutpeer00.lnd.ops.eu.uu.net!lnewsinpeer01.lnd.ops.eu.uu.net!emea.uu.net!newsfeed01.sul.t-online.de!t-online.de!webx
Newsgroups: adobe.scripting.indesign
Subject: [VB] Ittarate over pageitems won't work
Message-ID: <2ccd6887.-1@webx.la2eafNXanI>
Date: Fri, 12 Sep 2003 02:59:45 -0700
Lines: 39
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit