Hi,
I have a winforms application where user can create a Word doc with data previously entered.
Once the doc has been created (from a template dotm file), a table of content is updated.
My problem is that I have 2 titles in the template that already have been defined as Heading 1 and so are in the table of contents, but some titles that are added programmaticely have to be in Heading 2 to appear also in the table of contents.
I've done this:
The text added is in the same style as Heading 2 but does not appear in the table of contents and when I click on the text, the Heading 2 style in the style library is not selected...
I don't really understand why it doesn't work...
I have a winforms application where user can create a Word doc with data previously entered.
Once the doc has been created (from a template dotm file), a table of content is updated.
My problem is that I have 2 titles in the template that already have been defined as Heading 1 and so are in the table of contents, but some titles that are added programmaticely have to be in Heading 2 to appear also in the table of contents.
I've done this:
Code:
oPara = oDoc.Content.Paragraphs.Add(oDoc.Bookmarks.Item("\endofdoc").Range)
oPara.Style = Word.WdBuiltinStyle.wdStyleHeading2
If IsDBNull(dgvInventory.Rows(i).Cells(4).Value) Or dgvInventory.Rows(i).Cells(4).ToString = String.Empty Then
oPara.Range.Text = dgvInventory.Rows(i).Cells(3).Value & vbCr
Else
oPara.Range.Text = dgvInventory.Rows(i).Cells(3).Value & ": " & dgvInventory.Rows(i).Cells(4).Value & vbCr
End If
I don't really understand why it doesn't work...