0

Dim excelapp as new Microsoft.Office.Interop.Excel.Application

Dim newWorkbook as Microsoft.Office.Interop.Excel.Workbook

'Get excelfile and remove password

excelapp.Visible= False

newWorkbook=excelapp.Workbooks.Open(File_Name, 0, True, 5, password, "", False, Microspft.Office.Interop.Excel.XlPlatform.xlWindows, "", True, False, 0,True, False, False)

TempExcelFileName = String.format(" {0}{1}", "", Path.GetfileName(File_Name))

TempExcelFilePath=String.Format({0}/{1}", Path.GetDirectoryName(File_Name), TempExcelFileName)

'create new excel file and remove password

newWorkbook.SaveAs(TempExcelFilePath, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookDefault, "", "", False, False, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type. missing)

newWorkbook.Close()

System.Runtime.InteropServices.Marshal.ReleaseComObject(newWorkbook)

excelapp.quit()

System.Runtime.InteropServices.Marshal.ReleaseComObject(excelapp)

File.Delete(File_Name)

File.Move(TempExcelFilePath, File_Name)

  • A post that is just code (and not formatted correctly) is not really a question for this site, take a look at the site tour and learn how this site works to get the most out of it. – Hursey Sep 12 '22 at 20:19
  • As for you actual question, and this is purely based on my experience, while debugging it is not uncommon for COM processes (Such as Office.Interops) to terminate as expected. In a release build though, everything seem to quit. I avoid using office.interops where I can as there are many 3rd party libraries around now that make much more robust solutions – Hursey Sep 12 '22 at 20:23

0 Answers0