We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

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.
http://www.aspose.com/docs/display/wordsnet/Working+with+Bookmarks

<span style=“font-size:
10.0pt;font-family:“Courier New”;color:#2B91AF;mso-no-proof:yes”>Document<span style=“font-size:10.0pt;font-family:“Courier New”;mso-no-proof:yes”> doc = new Document(MyDir

  • “in.docx”);<o:p></o:p>

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:
http://www.aspose.com/docs/display/wordsnet/Object+Model+Overview
http://www.aspose.com/docs/display/wordsnet/Composition+Diagrams

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

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.