Free Support Forum -

Adding Comment causes object reference error

Have a word doc that is created using Aspose.Words and i wanted to add a comment after a particular line in the doc.

For simplicity my code is something like this:

Dim license As Aspose.Words.License = New Aspose.Words.License


Dim doc As Document = New Document()

Dim builder As DocumentBuilder = New DocumentBuilder(doc)

With builder

'Set page margins

.PageSetup.LeftMargin = 72

.PageSetup.RightMargin = 72

.PageSetup.TopMargin = 40



.Font.Color = System.Drawing.Color.Blue

.Font.Underline = Underline.Single

.InsertHyperlink("here", "\\lancpa-clu\shared\Case Letters\OpeningExamples.pdf", False)

.Font.Color = System.Drawing.Color.Black

.Font.Underline = Underline.None

Dim c As New Comment(doc)

c.Paragraphs.Add(New Paragraph(doc))

c.FirstParagraph.Runs.Add(New Run(doc, "This is a Test comment."))



doc.Save("\\lancpa-clu\Shared\Case Letters\Testing\" & txtFileName.Text.Trim & ".doc")

I get the error on the save. If I take out the comment part it works fine.

What am I doing wrong?



<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. I cannot reproduce the problem on my side. Please try using the latest version of Aspose.Words. You can download it from here:

Hope this helps.

Best regards.