Pull Topic & Page Number from within Document

Hi Ray,

I’m unable to reproduce the issue with that file, here is the “output.docx” file that I get:

Are you loading the right file into a DocumentModel?
In other words, are you using this:

Dim document = DocumentModel.Load("Inspection Report - 2400028.docx")

Regards,
Mario

Hi Mario,

No, there is no need to load the document while I’m building the report.
The idea here is to get the page numbers while building the report so that when I open the document and look into our summary page of the inspection, the page numbers are already set to the page number.

Regards,
Ray

Ray, unfortunately, I don’t understand what you’re saying…

The project you sent me loads an input DOCX file into a DocumentModel, is this not the case that you have?
How is that input DOCX file generated, are you creating it with GemBox.Document?

In that case, you’re probably creating a TOC element as well. This would explain the " 1. Variable ‘toc’ hides a variable in the enclosed block." error that you mentioned.
I’m guessing that what you’re missing is updating TOC and page numbers, see our TOC example:

Nevertheless, please create a Visual Studio project that reproduces your exact issue so that we can help you out with it.

Hi Mario,

No Problem.

So, when I’m building the report, there are sections. One section in particular is called “Summary.”

Within the summary, I need to provide page numbers for the many different sections within the report. This is why the

DocumentModel.Load

method will not work.

I need to get the page number per item; to the referencing section of the report.

I assumed that building the TOC first, using the “Find” string method and gathering the page number would work. I would then put that page number in the summary next to its rightful category.

Example:

Kind regards,
Ray