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

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 (here). After that, you can post your question and our members will help you out.