VBA & Macro Problems

Fix Error 438 When Updating a Word Table of Contents with VBA

Tauseeq MagsiTauseeq Magsi Nov 14, 2026 868 views

Question details

Update a Word table of contents from Access VBA using late binding without triggering error 438.

Fix Error 438 When Updating a Word Table of Contents with VBA
Product
Microsoft Word and Microsoft Access VBA
Device & OS
not provided
Scenario
An Access macro automates Word and updates a table of contents in a merged document.
Observed behavior
The update raises error 438 when the code uses an incorrect collection name or object reference.
Before you start

Confirm that the merged Word document contains a table of contents and identify the VBA variable that refers to that document, rather than the Word application. In Access, open the relevant module in the VBA editor to inspect the update code.

Solution 1Recommended

Update the merged document's TablesOfContents collection

Use this approach when Access raises error 438 while updating a Word table of contents through a late-bound document object.

The Word document collection is named TablesOfContents, with an s after Table and Contents. The update call must be made on the merged document object, not on the Word application.

1
Find the document reference

In the Access VBA editor, locate the variable that refers to the merged Word document. The following steps assume it is named oWord and is declared As Object for late binding.

2
Correct the update call

Replace the incorrect collection reference with: oWord.TablesOfContents(1).Update. This updates the first table of contents in the document.

3
Fix the With block

If the code uses With oWord, call .TablesOfContents(1).Update inside that block. Remove an incorrect .oWord reference inside the block, because it attempts to access a member of the document rather than the variable itself.

4
Check before updating

If the document may not contain a table of contents, check its collection first: If oWord.TablesOfContents.Count > 0 Then oWord.TablesOfContents(1).Update. Run the Access procedure again and verify the updated contents in Word.

Update the merged document's TablesOfContents collection
If oWord is the application: Use a separate Object variable for the merged document and call TablesOfContents on that variable. Do not assume the active document is the merged output without checking.
Free Microsoft Office alternative

Work with Word documents in WPS Writer

WPS Office is a free, lightweight alternative with a familiar interface for opening and editing Word documents. It can help you move everyday document work to WPS, although it does not fix Microsoft Word VBA errors and macro compatibility should be tested separately.

Open and edit Microsoft Word DOCX and DOC filesWork with headings and tables of contents in WPS WriterUse a familiar interface for everyday document editingMove compatible documents into a free, lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

Why does the table of contents update raise error 438?

Error 438 can occur if the code uses an unsupported member name or calls the collection on the wrong object. Check that the name is TablesOfContents and that the variable refers to the Word document.

How do I update the first table of contents with late binding?

With a document variable named oWord declared As Object, use oWord.TablesOfContents(1).Update. Ensure that oWord refers to the merged document and that the document contains a table of contents.

What should I write inside With oWord?

Use .TablesOfContents(1).Update inside the With oWord block. A reference such as .oWord attempts to access an oWord member of the object and is not needed to refer to the variable.

How can I avoid updating a table of contents that does not exist?

Check oWord.TablesOfContents.Count before using index 1. If the count is zero, insert a table of contents in Word or adjust the automation to create one before updating.