|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Cleaning up Excel After using Excel InteropI am having an issue with my code below not closing EXCEL.EXE when I tell it do. Any help would be appreciated. ----- Dim excel As Microsoft.Office.Interop.Excel.Application Dim wb As Microsoft.Office.Interop.Excel.Workbook Dim ws As Microsoft.Office.Interop.Excel.Worksheet excel = New Microsoft.Office.Interop.Excel.Application wb = excel.Workbooks.Open(strDynamicFileName) ws = wb.Sheets.Item(1) excel.Visible = False wb.Activate() .... REMOVED FUNCTION CODE HERE ' Clean up System.Runtime.InteropServices.Marshal.ReleaseComObject(ws) ws = Nothing wb.Close() System.Runtime.InteropServices.Marshal.ReleaseComObject(wb) wb = Nothing excel.Quit() System.Runtime.InteropServices.Marshal.ReleaseComObject(excel) excel = Nothing First, I would change the name of your Excel variable from "excel" to
something else. Second, I'd rearrange the code to be like this: Show quoteHide quote > ' Clean up > wb.Close() > excel.Quit() > System.Runtime.InteropServices.Marshal.ReleaseComObject(ws) > System.Runtime.InteropServices.Marshal.ReleaseComObject(wb) > System.Runtime.InteropServices.Marshal.ReleaseComObject(excel) > ws = Nothing > wb = Nothing > excel = Nothing
business layer, data access layer , presentation layer for asp.net using C#.net
Convert OEM to Unicode class types in vb.net What is the return type of Session("Something")? Reflection and SetValue .arrrrggggggghhhhh Inherited form Name from Base How to manage a exception in a Aplications Questions, questions...... How do I find the computer name on which my program is running? Lock a .dll |
|||||||||||||||||||||||