Question

I have the following problem: I'd like to create a dynamic table of content using aspose.words and vb.net. I did it using this code:

Dim doc As New Document()
Dim builder As New DocumentBuilder(doc2)
builder.InsertTableOfContents("""\o ""1-3"" ""\h ""\z ""\u")
builder.InsertBreak(BreakType.PageBreak)
[...]
doc.UpdateFields()
doc.Save(tempPath, SaveFormat.Docx)

and it works. The problem is that when no table of content entries are found I obtain in my docx:

No table of contents entries found.

Is it possible to write something like that (pseudo-code):

If (no_entries_found) Then
    table_of_content.display=false
Endif

Thanks so much,

Daniele

Was it helpful?

Solution

I resolved using a workaround... if the content is equal to "No table of contents entries found." i replace it with "". If someone has better ideas I'll be glad to hear them.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top