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 / Word / Programming / January 2005

Tip: Looking for answers? Try searching our database.

One more TOC question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
tomcat - 07 Jan 2005 22:05 GMT
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
Jonathan West - 07 Jan 2005 22:27 GMT
> When I already know a TOC item
> (MyDoc.TablesOfContents[1].Range.Paragraphs[1]), how can i select the
[quoted text clipped - 10 lines]
>
> 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.

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup

tomcat - 07 Jan 2005 22:58 GMT
Thanks for reply, I could find the PageRef property in the paeragraph
object, I am using c#. any idea?
Jonathan West - 08 Jan 2005 01:34 GMT
> 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

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup

tomcat - 08 Jan 2005 02:28 GMT
 
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.