Sunday, June 6, 2010

Writing Autotext Entries in Vsto

Finding AutoText Enties from word2007 and Writing on Selected Range
Requirement:-
Vs2oo8(Vsto)
Word
and Bit of Interest

Let Start :-


Go to -- Insert Tab -- Quick parts -- Building Block and U will See some What Image Like That


Know Double Click on Name --- U will See The window note Down Name
Know put the Code


Code:-

Word.Template template = (Word.Template)this.Application.ActiveDocument.get_AttachedTemplate();

//Adding name property of AutoText in This cas I have "Word_auto_text_Avinash"
//and Output would be "Avinash"
object agendaObj = "Word_auto_text_Avinash";
object richText = true;

Word.Range range2 = this.Paragraphs[1].Range;

Word.AutoTextEntry agenda = template.AutoTextEntries.get_Item(ref agendaObj);
agenda.Insert(range2, ref richText);

Output:-

No comments:

Post a Comment