Free Support Forum - aspose.com

Document Save - Object Reference not set

Hi People,

I'm in the process of evaluating your wonderful products. I'm having a problem when I create a new document (from a Word 2000 template), move through the bookmarks replacing them with data and then saving the document. When I save the document, I get an object reference not set... message. I'm working in VB.NET 2.0. I've attached the original template to help.

Regards,

Tim

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

Thanks for your request. Could you please provide me code example that will allow me to reproduce this issue? I will investigate this problem and provide you more information.

Best regards.

Hi Alexey,

The code is fairly verbose. I've attached a zipped vb file that should show what I'm doing. Let me know if that is OK for you.

Tim

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

Thanks for additional information. As I see from your code you just insert text at the bookmark. I tried this on my side and all works fine. I use the latest version of Aspose.Words for testing. See the following code:

Document doc = new Document(@"Test184\in.dot");

DocumentBuilder builder = new DocumentBuilder(doc);

foreach (Bookmark book in doc.Range.Bookmarks)

{

builder.MoveToBookmark(book.Name);

builder.Write("test");

}

doc.Save(@"Test184\out.doc");

Maybe you can try using another overload of MoveToBookmark method.

builder.MoveToBookmark(book.Name, false, true);

Best regards.

That worked. Thanks. I’ll proceed with my testing and see if anything else crops up.