Free Support Forum - aspose.com

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

license.SetLicense("\\borg\share\Installs\Aspose\Aspose.Words.lic")

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

.Writeln()

.Writeln()

.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."))

.CurrentParagraph.AppendChild(c)

.Writeln()

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?

Thanks

Hi

<?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:

http://www.aspose.com/community/files/51/.net-components/aspose.words-for-.net/category1188.aspx

Hope this helps.

Best regards.