Copy an Excel-Workshhet with an OLE Button

Oct 25 2012 10:44 AM

Hello Together,

searched for a looong time but didn't found the answer yet.

I will copy a worksheet from one workbook to another with the COM Interop service. This works fine but there is one Problem i can't get over:

On the sheet i copy, there is a button (OLEObject). If i copy this button to the other workbook, the source of the button (which you can specify with a right click) changes. It relies to the original ExcelSheet instead of the Makro inside my new workbook. I do the copying with the following code:



...
Excel.Worksheet workSheet1 = workBook1.Worksheets.get_Item("Headinformation");
workSheet1.Copy(Type.Missing, Type.Missing);
...



How can i copy my workSheet1 without changing the SourceName-Attribute of the OLEObject?

I hope my explanation is okay... :)