Link to home
Create AccountLog in
Avatar of kunal singh
kunal singh

asked on

button on being saved in word VSTO

i have this pieace of code

 private void button2_Click(object sender, RibbonControlEventArgs e)
        {
            Microsoft.Office.Tools.Word.Controls.Button salesButton;
            Document vstodoc = Globals.Factory.GetVstoObject(Globals.ThisAddIn.Application.ActiveDocument);
            Microsoft.Office.Interop.Word.Application objApplication = Globals.ThisAddIn.Application;
            Microsoft.Office.Interop.Word.Selection objSelection = objApplication.Selection;
            Microsoft.Office.Interop.Word.Range objRange = objSelection.Range;
            salesButton = vstodoc.Controls.AddButton(objRange, 20, 20, "salesButton");
            salesButton.Text = "Calculate Total Sales";
        }

Open in new window

when i click on the button a button is inserted inside word doc but when i save it and try to reopen the word document the button is not there

before i save the word doc: 
User generated imageAfter i save the Word Doc: After i save the Word Doc: