0

I've ran into a problem where the sheet.Copy() method crashes saying "Interface not registered" I am trying to copy a worksheet from one workbook to another opened up one. This is the code (it is inside a For loop):

xlWorkbook3 = xlApp3.Workbooks.Open(finalDir);
Excel.Worksheet xl = xlWorkbook3.Sheets[1];
xl.Copy(Before: xlWorksheet2);
Marshal.ReleaseComObject(xl);
Tal Hadad
  • 79
  • 1
  • 8
  • This creates more than 10 instances of Excel in the background even if I close xlApp3 and its workbook – Tal Hadad Feb 07 '17 at 09:32
  • You want to open one (1) excel file and from this file create multiple new/existing excel files? You are going to have to be more specific and minimum show the loop that creates these excel applications as from what I can tell from your requirement, there is only one instance needed for this. The check for if a file “existed” is awkward… it either exist or it doesn’t. – JohnG Feb 07 '17 at 11:17
  • Please be aware that `xlApp3.Quit()` or the following line may not completely dispose of the Excel application. See http://stackoverflow.com/questions/158706/how-do-i-properly-clean-up-excel-interop-objects?rq=1 – UndeadBob Feb 07 '17 at 17:27
  • No, it means that tge file has already existed before running the program, so it won't replace information but add information – Tal Hadad Feb 08 '17 at 05:57

0 Answers0