How to know the document already add table of content

Discussion in 'Word Programming' started by moonhkt, Jul 2, 2012.

  1. moonhkt

    moonhkt Guest

    Hi All


    Word 2007.

    How to know the document already add table of content ? if exist, how to refresh the table of content ?

    moonhkt
     
    moonhkt, Jul 2, 2012
    #1
    1. Advertisements

  2. moonhkt

    Stefan Blom Guest

    The following macro will update all tables of contents in the active
    document:

    Sub UpdateAllTablesOfContents()
    Dim toc As TableOfContents
    For Each toc In ActiveDocument.TablesOfContents
    toc.Update
    Next toc
    End Sub

    If you need assistance, see http://www.gmayor.com/installing_macro.htm.

    Stefan Blom
    Microsoft Word MVP





    On 2012-07-02 16:53, moonhkt wrote:
    > Hi All
    >
    >
    > Word 2007.
    >
    > How to know the document already add table of content ? if exist, how to refresh the table of content ?
    >
    > moonhkt
    >
     
    Stefan Blom, Jul 3, 2012
    #2
    1. Advertisements

  3. moonhkt

    moonhkt Guest

    On Tuesday, July 3, 2012 4:49:51 PM UTC+8, Stefan Blom wrote:
    > The following macro will update all tables of contents in the active
    > document:
    >
    > Sub UpdateAllTablesOfContents()
    > Dim toc As TableOfContents
    > For Each toc In ActiveDocument.TablesOfContents
    > toc.Update
    > Next toc
    > End Sub
    >
    > If you need assistance, see http://www.gmayor.com/installing_macro.htm.
    >
    > Stefan Blom
    > Microsoft Word MVP
    >
    >
    >
    >
    >
    > On 2012-07-02 16:53, moonhkt wrote:
    > > Hi All
    > >
    > >
    > > Word 2007.
    > >
    > > How to know the document already add table of content ? if exist, how to refresh the table of content ?
    > >
    > > moonhkt
    > >


    Thank. But how to check document already have TOC ?
     
    moonhkt, Jul 4, 2012
    #3
  4. moonhkt

    Stefan Blom Guest

    The macro will run without problems even if there are no TOCs in the
    document. However, if you want to test for the presence of a TOC (in
    some other context), you can use the Count property of the
    TablesOfContents collection:

    If ActiveDocument.TablesOfContents.Count > 0 Then
    'code goes here
    End If

    Stefan Blom
    Microsoft Word MVP





    On 2012-07-04 06:43, moonhkt wrote:
    > On Tuesday, July 3, 2012 4:49:51 PM UTC+8, Stefan Blom wrote:
    >> The following macro will update all tables of contents in the active
    >> document:
    >>
    >> Sub UpdateAllTablesOfContents()
    >> Dim toc As TableOfContents
    >> For Each toc In ActiveDocument.TablesOfContents
    >> toc.Update
    >> Next toc
    >> End Sub
    >>
    >> If you need assistance, see http://www.gmayor.com/installing_macro.htm.
    >>
    >> Stefan Blom
    >> Microsoft Word MVP
    >>
    >>
    >>
    >>
    >>
    >> On 2012-07-02 16:53, moonhkt wrote:
    >>> Hi All
    >>>
    >>>
    >>> Word 2007.
    >>>
    >>> How to know the document already add table of content ? if exist, how to refresh the table of content ?
    >>>
    >>> moonhkt
    >>>

    >
    > Thank. But how to check document already have TOC ?
    >
     
    Stefan Blom, Jul 4, 2012
    #4
  5. moonhkt

    moonhkt Guest

    Stefan Blomæ–¼ 2012å¹´7月4日星期三UTC+8下åˆ8時07分37秒寫é“:
    > The macro will run without problems even if there are no TOCs in the
    > document. However, if you want to test for the presence of a TOC (in
    > some other context), you can use the Count property of the
    > TablesOfContents collection:
    >
    > If ActiveDocument.TablesOfContents.Count > 0 Then
    > 'code goes here
    > End If
    >
    > Stefan Blom
    > Microsoft Word MVP
    >
    >
    >
    >
    >
    > On 2012-07-04 06:43, moonhkt wrote:
    > > On Tuesday, July 3, 2012 4:49:51 PM UTC+8, Stefan Blom wrote:
    > >> The following macro will update all tables of contents in the active
    > >> document:
    > >>
    > >> Sub UpdateAllTablesOfContents()
    > >> Dim toc As TableOfContents
    > >> For Each toc In ActiveDocument.TablesOfContents
    > >> toc.Update
    > >> Next toc
    > >> End Sub
    > >>
    > >> If you need assistance, see http://www.gmayor.com/installing_macro.htm..
    > >>
    > >> Stefan Blom
    > >> Microsoft Word MVP
    > >>
    > >>
    > >>
    > >>
    > >>
    > >> On 2012-07-02 16:53, moonhkt wrote:
    > >>> Hi All
    > >>>
    > >>>
    > >>> Word 2007.
    > >>>
    > >>> How to know the document already add table of content ? if exist, howto refresh the table of content ?
    > >>>
    > >>> moonhkt
    > >>>

    > >
    > > Thank. But how to check document already have TOC ?
    > >


    Thank. It works.
     
    moonhkt, Jul 5, 2012
    #5
  6. moonhkt

    Stefan Blom Guest

    You are welcome!

    Stefan Blom
    Microsoft Word MVP





    On 2012-07-05 13:39, moonhkt wrote:
    > Stefan Blomæ–¼ 2012å¹´7月4日星期三UTC+8下åˆ8時07分37秒寫é“:
    >> The macro will run without problems even if there are no TOCs in the
    >> document. However, if you want to test for the presence of a TOC (in
    >> some other context), you can use the Count property of the
    >> TablesOfContents collection:
    >>
    >> If ActiveDocument.TablesOfContents.Count > 0 Then
    >> 'code goes here
    >> End If
    >>
    >> Stefan Blom
    >> Microsoft Word MVP
    >>
    >>
    >>
    >>
    >>
    >> On 2012-07-04 06:43, moonhkt wrote:
    >>> On Tuesday, July 3, 2012 4:49:51 PM UTC+8, Stefan Blom wrote:
    >>>> The following macro will update all tables of contents in the active
    >>>> document:
    >>>>
    >>>> Sub UpdateAllTablesOfContents()
    >>>> Dim toc As TableOfContents
    >>>> For Each toc In ActiveDocument.TablesOfContents
    >>>> toc.Update
    >>>> Next toc
    >>>> End Sub
    >>>>
    >>>> If you need assistance, see http://www.gmayor.com/installing_macro.htm..
    >>>>
    >>>> Stefan Blom
    >>>> Microsoft Word MVP
    >>>>
    >>>>
    >>>>
    >>>>
    >>>>
    >>>> On 2012-07-02 16:53, moonhkt wrote:
    >>>>> Hi All
    >>>>>
    >>>>>
    >>>>> Word 2007.
    >>>>>
    >>>>> How to know the document already add table of content ? if exist, how to refresh the table of content ?
    >>>>>
    >>>>> moonhkt
    >>>>>
    >>>
    >>> Thank. But how to check document already have TOC ?
    >>>

    >
    > Thank. It works.
    >
     
    Stefan Blom, Jul 6, 2012
    #6
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. Abhilash
    Replies:
    1
    Views:
    117
    Howard Kaikow
    Aug 21, 2005
  2. JethroUK©

    UK Date bug in Word XP - Anyone know a fix?

    JethroUK©, Apr 7, 2006, in forum: Word Programming
    Replies:
    7
    Views:
    100
    JethroUK©
    Apr 9, 2006
  3. jo

    Content Controls and Building Blocks

    jo, Sep 22, 2006, in forum: Word Programming
    Replies:
    0
    Views:
    188
  4. Vsn

    Tabel find and grab cell content

    Vsn, Nov 12, 2006, in forum: Word Programming
    Replies:
    5
    Views:
    130
    Jezebel
    Nov 16, 2006
  5. Prince Rayet

    Error: Template File Already In Use (Long Post)

    Prince Rayet, Apr 11, 2007, in forum: Word Programming
    Replies:
    2
    Views:
    108
    Prince Rayet
    Apr 11, 2007
  6. kozaw
    Replies:
    5
    Views:
    203
    Cindy M.
    Jun 14, 2007
  7. mit

    Linking table content to radio buttons

    mit, Dec 9, 2009, in forum: Word Programming
    Replies:
    1
    Views:
    180
    Graham Mayor
    Dec 10, 2009
  8. Lars Brownies

    Check if Word doc is already opened

    Lars Brownies, Jan 29, 2010, in forum: Word Programming
    Replies:
    2
    Views:
    314
    Lars Brownies
    Jan 29, 2010
Loading...