🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: adobe.scripting.indesign
12 messages
12 total messages Started by Kathleen Spracklen Sun, 12 May 2002 16:18
VB and 2.0 Page number of a Table Cell
#21043
Author: Kathleen Spracklen
Date: Sun, 12 May 2002 16:18
7 lines
979 bytes
Hello All, 

If myCell is an arbitrary cell in a table that extends across many document pages, can anyone tell me how I would determine what page number this particular cell appears on? 

Thanks much, 

Kathleen
Re: VB and 2.0 Page number of a Table Cell
#21049
Author: Olav Kvern
Date: Mon, 13 May 2002 18:21
15 lines
1455 bytes
Kathleen-- 

The parent of the cell is the table, and the parent of the table is a text frame, and the parent of a text frame is a page, and the name of the page is the page number.<g> 

So: 

Rem Given a reference to a cell "myCell" (and assuming that the text frame containing the table is not Rem inside another frame or group... myPageName = myCell.Parent.Parent.Parent.Name myPageIndex = myCell.Parent.Parent.Parent.Index  

I call this "climbing the Parent tree." 

If the text frame is inside another frame, or inside a group, it gets more complicated. 

Thanks, 

Ole
Re: VB and 2.0 Page number of a Table Cell
#21050
Author: Kathleen Spracklen
Date: Mon, 13 May 2002 18:34
11 lines
1126 bytes
Hi Ole, 

I just tried it out on a table that is split across page 19 and page 20 in a certain document.  

Climbing the parent tree told me that my cell was on page 19. It isn't its actually located on page 20. 

In fact this method tells me that every cell in this table is located on page 19. They aren't. Many cells are on page 20.  

Thanks, 

Kathleen
Re: VB and 2.0 Page number of a Table Cell
#21052
Author: Olav Kvern
Date: Mon, 13 May 2002 20:00
7 lines
1165 bytes
Kathleen-- 

Sorry, I didn't read your first post closely enough. This one will take some thinking about--it's going to be possible (I have at least one sleazy method in mind that should work), but it's looking a bit tricky. I'll post an example as soon as I can. 

Thanks, 

Ole
Re: VB and 2.0 Page number of a Table Cell
#21055
Author: Kathleen Spracklen
Date: Mon, 13 May 2002 20:18
3 lines
863 bytes
Thanks for looking into this!! 

-- Kathleen
Re: VB and 2.0 Page number of a Table Cell
#21058
Author: Olav Kvern
Date: Mon, 13 May 2002 21:34
13 lines
1393 bytes
Kathleen-- 

Okay, I've got one. Now...I told you this would be sleazy, right?<g> 

Rem Given a cell "myCell" in a document "myDocument"... Set myPolygon = myCell.CreateOutlines(False) Set myPage = myPolygon.Item(1).Parent myDocument.Undo myPageName = myPage.Name myPageIndex = myPage.Index  

When you use CreateOutlines with the DeleteOriginal parameter set to false, you get a polygon floating on top of the original cell. That polygon is not part of the table, so its parent is the page. You can then safely undo the action to get rid of the converted characters. 

Hope this works for you--at least until I can come up with a more elegant method. 

Thanks, 

Ole
Re: VB and 2.0 Page number of a Table Cell
#21057
Author: Kathleen Spracklen
Date: Mon, 13 May 2002 21:55
9 lines
976 bytes
Hi Ole, 

Hey, it works! I'll be visiting the rows of a table trying to locate the page breaks, in case that affects your search for more elegant methods. 

I really appreciate the help. This will get me by for now. 

Thanks, 

Kathleen
Re: VB and 2.0 Page number of a Table Cell
#21059
Author: Olav Kvern
Date: Mon, 13 May 2002 22:07
9 lines
1359 bytes
Kathleen-- 

I also meant to mention that the index of the table in the story is off by one--when you get Table.StoryOffset, you'd think that you could refer to the character containing the table using Story.Characters.Item(Table.StoryOffset), but you really need to use Item(Table.StoryOffset+1).  

If you do this, you can compare the page of the character containing the table to the page of the character following the table (which is Story.Characters.Item(Table.StoryOffset + 2)). If the two characters have the same Character.ParentTextFrame then you know that the table does not span multiple text frames or pages. 

Thanks, 

Ole
Re: VB and 2.0 Page number of a Table Cell
#21060
Author: Kathleen Spracklen
Date: Mon, 13 May 2002 22:47
7 lines
1383 bytes
OK, I give up. How can I get to the story referenced in Story.Characters.Item(Table.StoryOffset)? If I try to go from the table, I can get to the text frame that contains the table. It has one character in its characters collection, which I would have thought was the table. But then what's the character following the table?  

I'm not getting something here. 

Thanks, 

Kathleen
Re: VB and 2.0 Page number of a Table Cell
#21061
Author: Kathleen Spracklen
Date: Mon, 13 May 2002 22:49
5 lines
1072 bytes
P.S.  If I look at myDocument.Stories.Count, I see that there are 1081 stories. Is one of those going to contain my table? If so, how can I tell which one? 

Thanks, 

Kathleen
Re: VB and 2.0 Page number of a Table Cell
#21063
Author: Olav Kvern
Date: Mon, 13 May 2002 23:04
17 lines
1742 bytes
Kathleen-- 

The one character contains the table, but it is not the table itself. You can get the table using a variety of references, including: 

Story.Tables.Item(1) Rem Given a reference to the paragraph containing the table: Paragraph.Tables.Item(1) Rem Given a reference to the character containing the table: Character.Tables.Item(1)  

To find a table in a given story, I would simply iterate through the stories looking for a table that matched whatever makes the table I'm looking for unique (this is a great use for the Label property).  

Or you could use search to find an unique string in the table, then get the parent of the found text (it'll be the cell), and then work from there. 

re: "But then what's the character following the table?" 

If there's no character following the table, you might consider adding a carriage return after the table (just so that you can use the trick I mentioned earlier of getting the next character). 

Thanks, 

Ole
Re: VB and 2.0 Page number of a Table Cell
#21062
Author: Kathleen Spracklen
Date: Mon, 13 May 2002 23:23
3 lines
829 bytes
Thanks, you've given me a lot to work with here! 

-- Kathleen
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads