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 / October 2005

Tip: Looking for answers? Try searching our database.

Is Insertion Point in Table of Contents (TOC)?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
George Lee - 19 Oct 2005 15:36 GMT
How do tell if the insertion point in a table of contents (TOC)?
Jezebel - 19 Oct 2005 22:27 GMT
Dim pField as Word.Field
Dim pTOC as Word.Range

'First, find the TOC  --
For each pField in ActiveDocument.Fields
   if pField.Type = wdFieldTOC then
       set pTOC = pField.Result
       exit for
   end if
Next

'Now check if the selection is inside it
If Selection.Start >= pTOC.Start and Selection.End <= pTOC.End then
   ... yes it is

Note that there's an ambiguity about 'selection within the TOC' -- do you
mean wholly contained within, or merely includes at least some of it? (eg
you can select a range with the start within and the end outside, or vice
versa).

> How do tell if the insertion point in a table of contents (TOC)?
George Lee - 21 Oct 2005 16:23 GMT
Thanks. It works. Also, I was determining this for the insertion point or the
start of the range. The trick was to find this table in the first place.

However, it seems different than what I was expecting. I used the .Selection
information to see if either the Table.Count or Fields.Count equaled 1. In
both cases, the count was zero.

> Dim pField as Word.Field
> Dim pTOC as Word.Range
[quoted text clipped - 17 lines]
>
> > How do tell if the insertion point in a table of contents (TOC)?
Jezebel - 23 Oct 2005 00:14 GMT
Table.Count returns zero because a TOC is not a "table" (of the sort that
you get from Table > Insert). I don't know why Fields.Count returns zero in
this case.

It doesn't help here, but the Information() function tells you if the
insertion point is within a true table.

> Thanks. It works. Also, I was determining this for the insertion point or
> the
[quoted text clipped - 26 lines]
>>
>> > How do tell if the insertion point in a table of contents (TOC)?
 
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.