Solved

Problems with TablesOfContents.Update in XP

Posted on 2003-11-14
15
952 Views
Last Modified: 2008-03-06
Hi!

We have a number of macros set up for our book projects. Everything worked swell but after upgrading to Windows XP something strange happened. Suddenly TablesOfContents.Update wouldn't run.

Error message:

  "Method 'Update' of object 'TablesOfContents' failed"

Code:

  If (ActiveDocument.TablesOfContents.Count > 0) Then
        ActiveDocument.TablesOfContents(1).Update          '// We get here but the 'Update' method won't run
  End If


The method 'UpdatePageNumbers' works fine though.

If you could give me an explanation and/or a solution I would be most grateful.

Thanks!
0
Comment
Question by:Hermund
  • 7
  • 7
15 Comments
 
LVL 37

Expert Comment

by:Joanne M. Orzech
ID: 9750024
Although I don't have Windows XP here, you could try re-recording the macro and see what code you get.  Get a document on your screen that contains a Table of Contents.  Then go to Tools, Macro, Record New Macro, give it a name, and go through the steps you want the macro to perform.  After ending recording the macro, press Alt F11 to view the code.  You can then see how and if it differs from your previous code.

0
 
LVL 37

Expert Comment

by:Joanne M. Orzech
ID: 9750055
0
 

Author Comment

by:Hermund
ID: 9762518
Hi!

Thanks for the reply!

I tried what you suggested and the following macro code was created:

Sub TOCupdate()
'
' TOCupdate Macro
' Macro recorded 17.11.2003 by hermund
'
    CommandBars("Outlining").Visible = True
    WordBasic.UpdateTableOfContents
End Sub


When I run this macro only the page numbers are updated, not the titles. Strange!

The Update TOC function (in Tools/Outlining) works fine.
0
 
LVL 37

Expert Comment

by:Joanne M. Orzech
ID: 9763336
Did you try adding:

Dim TableOfContents as Object

?
0
 

Author Comment

by:Hermund
ID: 9763362
I'm not sure I understand.

Like this?

Sub TOCupdate()
'
' TOCupdate Macro
' Macro recorded 17.11.2003 by hermund
'
    Dim TableOfContents As Object

    CommandBars("Outlining").Visible = True
    WordBasic.UpdateTableOfContents
End Sub
0
 

Author Comment

by:Hermund
ID: 9763376
When you run the "Update TOC" commando you're asked whther to update page numbers only or update all. Default is page numbers only. That might be the reason why only the page numbers are updated when using TOCupdate.
0
 
LVL 37

Expert Comment

by:Joanne M. Orzech
ID: 9763377
Usually, it is good practice to declare variables.  If you use Option Explicit, it will require you to declare all variables in your project.  But just try for now:

Dim TableOfContents As Object

Sub TOCupdate()
'
' TOCupdate Macro
' Macro recorded 17.11.2003 by hermund

    CommandBars("Outlining").Visible = True
    WordBasic.UpdateTableOfContents
End Sub
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 37

Expert Comment

by:Joanne M. Orzech
ID: 9763412
Go to Visual Basic Help (Alt F11 - Help) and type in TOC.  


ActiveDocument.TablesOfContents.Update 'should update entire table
ActiveDocument.TablesOfContents.UpdatePageNumber 'should update page numbers only


 

 
0
 

Author Comment

by:Hermund
ID: 9763466
I'm afraid it didn't help.

Could it be that there's a bug in the XP version?
0
 
LVL 37

Expert Comment

by:Joanne M. Orzech
ID: 9763518
hmmm - it could be - my home PC has XP and I'll have to try it there....will do that tonight as soon as I get home and let you know what I find.

0
 

Author Comment

by:Hermund
ID: 9763541
Thanks a lot!
0
 

Accepted Solution

by:
Hermund earned 0 total points
ID: 9770355
Hi there!

I figured out the problem now. I had called my method updateFields(). Apparently a new built-in method in the XP version had the same name. After changing the name everything worked swell.

Thanks for your help!

Hermund
0
 
LVL 37

Expert Comment

by:Joanne M. Orzech
ID: 9770872
Great! - you can go to Community Support and ask for a refund of your points.
0
 

Author Comment

by:Hermund
ID: 9770972
Done!

Thanks!

0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction Authors who set out to write any sort of lengthy piece for online submission—be it a long question or comment on a technical form, an article, or a substantial blog entry—often find it useful to work up a draft in an editor other t…
I'm writing to share my clumsy experience in using this elegant tool so you can avoid every stupid mistake I made. (I leave it to the authorities to decide if this deserves a place in the Knowledge archives.)  Now that I am on the other side of my l…
This video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now