troubleshooting Question

button on being saved in word VSTO

Avatar of kunal singh
kunal singh asked on
Microsoft OfficeC#Microsoft WordMicrosoft 365* VSTO
2 Comments1 Solution29 ViewsLast Modified:
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";

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: 
After i save the Word Doc: After i save the Word Doc:

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros