Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
640 views
in Technique[技术] by (71.8m points)

ms word - Automatically Update Page Numbers for Table of Contents in DOCX generated using OpenXML SDK

I have been able to successfully generate word document (.docx) using OpenXML SDK 2.5.

Can we directly update the page numbers in TOC of the generated document using OpenXML SDK I found few similar queries on Stack overflow.

[https://stackoverflow.com/questions/28348550/how-to-generate-table-of-contents-using-openxml-sdk-2-5]

[https://stackoverflow.com/questions/9762684/how-to-generate-table-of-contents-using-openxml-sdk-2-0/]

One of the ways is to have users click yes to update the Table of Contents on a modal dialog when they open the document the first time. Is there a way to avoid this modal dialog and user intervention but still update page numbers on opening the document the first time?

Thanks, Gagan

question from:https://stackoverflow.com/questions/66058273/automatically-update-page-numbers-for-table-of-contents-in-docx-generated-using

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Since the page numbers can be different depending on how the opening application renders the document, i don't think that there is a way to do that by means of the OpenXml-SDK.

You can update fields/tocs using a macro or automation: How to automatically update tables of contents


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...