Code snippet in aspose for the below ms word document code

Am new to aspose.words.
Can i know if the below code snippet be achieved using aspose.words:

WordApp.ActiveDocument.Bookmarks("Name").Select()
WordApp.Selection.Text = .UserName

Thanks,
vem

Hi Vem,

Thanks for your inquiry. Please use the following code snippet to achieve your requirement and read following documentation link for your kind reference.
https://docs.aspose.com/words/net/working-with-bookmarks/

Document doc = new Document(MyDir + "in.docx");
doc.Range.Bookmarks["name"].Text = "Aspose.Words";
doc.Save(MyDir + @"out.docx");

Moreover, please note that Aspose.Words is quite different from the Microsoft Word’s Object Model in that it represents the document as a tree of objects more like an XML DOM tree. If you worked with any XML DOM library you will find it is easy to understand and work with Aspose.Words. When you load a Word document into Aspose.Words, it builds its DOM and all document elements and formatting are simply loaded into memory. Please read the following articles for more information on DOM:
https://docs.aspose.com/words/net/aspose-words-document-object-model/
https://docs.aspose.com/words/net/logical-levels-of-nodes-in-a-document/

Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.

surprisingly, 2 days ago the same code threw object reference error. But it worked now

Thank you so much Tahir.

Hi Vem,

Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.