One more TOC question

T

tomcat

When I already know a TOC item
(MyDoc.TablesOfContents[1].Range.Paragraphs[1]), how can i select the
corespending content in the document?

What I am trying to do is that I have a TOC like:

Section 1
-- Section 1.1
-- Section 1.2

I need to copy the part of the document linked to the Section 1.2.
thanks for help

Tomcat
 
J

Jonathan West

tomcat said:
When I already know a TOC item
(MyDoc.TablesOfContents[1].Range.Paragraphs[1]), how can i select the
corespending content in the document?

What I am trying to do is that I have a TOC like:

Section 1
-- Section 1.1
-- Section 1.2

I need to copy the part of the document linked to the Section 1.2.
thanks for help

Tomcat

Hi Tomcat

If the paeragraph has a PAGEREF field included (making the page number into
a hyperlink) then you can extract the bookmark from the Code property fo the
field. That bookmark makes the heading paragraph. If you want the range of
the body text below it, then get the bookmark of the following TOC entry
page number, and then get the range from the start of the current bookmark
to the start of the next.
 
T

tomcat

Thanks for reply, I could find the PageRef property in the paeragraph
object, I am using c#. any idea?
 
J

Jonathan West

tomcat said:
Thanks for reply, I could find the PageRef property in the paeragraph
object, I am using c#. any idea?

Paragraph(n).Range.Fields(1).Code.Text

That property will give you the text of the field code, which will be
something like this

" PAGEREF _ToC3452435623 "

The second word is the name of the bookmark marking the heading in the body
of the document
 

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