Free Support Forum - aspose.com

Aspose Words- problem with changing bookmark text of Template file

Hi ASPOSE,

I have a MS Word template file (please check the attachment).
Its “Subject” bookmark has text value : "\u0013 DOCPROPERTY “Doc.Subject”\*CHARFORMAT \u0014\u0015"
I just want to change its text to “Hello World”.
But it raised error message : "Cannot insert a node of this type at this location."
It has complex structure in BookmarkStart object :

BookmarkStart :
NextSibling :
- Type : Fields.FieldStart
- Range.Text = “\u0013”
NextSibling :
- Type : Run
- Range.Text = " DOCPROPERTY “Doc.Subject”\*CHARFORMAT "
NextSibling :
- Type : Fields.FieldSeparator
- Range.Text = “\u0014”
NextSibling :
- Type : Fields.FieldEnd
- Range.Text = “\u0015”

So for my simple target (changing the text of “Subject” bookmark), do you have any clue ?
(it’s very urgent)
Thank in advance

Hi Loc,


Please try using the following simple code:

Document doc = new Document(filePath);

Bookmark bm = doc.Range.Bookmarks["Subject"];

bm.Text = "Hello World!";

doc.Save(MyDir + @"16.10.0.docx");


Best regards,

Hi Hafeez,

I would like to update the existing template file.
And it will raise error in the line of :
bm.Text = “Hello World!”;

Error message is “Cannot insert a node of this type at this location.”
Hi Loc,

Thanks for your inquiry. What version of Aspose.Words are you currently using?

After an initial test with Aspose.Words 16.10.0, I was unable to reproduce this issue on my side. I would suggest you please upgrade to the latest version of Aspose.Words. You can download it from the following link. I hope, this helps.
http://www.aspose.com/downloads/words/net

In case the problem still remains, please create a standalone console application (source code without compilation errors) that helps us reproduce your problem on our end and attach it here for testing.

Best regards,

Hi Hafeez,

I’m using version 16.8.
I updated to 16.10 and it worked.
Thank you !!