I made this progarm in Visual studio 2005 vith COM Interop, I want to change the program so it does'n turn of excel and let the user control the application insted after the macro have run.
What lines to remowe?? i guess those marked with: <--**
Code:
Dim oExcel As Excel.Application
Dim oBook As Excel.Workbook
Dim oBooks As Excel.Workbooks
'Start excel
oExcel = CreateObject("Excel.Application")
oExcel.Visible = True
oBooks = oExcel.Workbooks
'Walkaround för bug
'http://support.microsoft.com/default.aspx?scid=kb;en-us;320369
Dim oldCI As System.Globalization.CultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture
System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo("en-US")
oBook = oBooks.Open("C:\ASEDT.xls")
'Run macro / sub rutine
oExcel.Run("MyOpen", parameter)
'Close the wokbook and quit Excel
oBook.Close(False)
System.Runtime.InteropServices.Marshal.ReleaseComObject(oBook)
oBook = Nothing
System.Runtime.InteropServices.Marshal.ReleaseComObject(oBooks)
oBooks = Nothing
oExcel.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(oExcel)
oExcel = Nothing
'Walkaround för bug
System.Threading.Thread.CurrentThread.CurrentCulture = oldCI
What lines to remowe?? i guess those marked with: <--**
Code:
oBook.Close(False) <--**
System.Runtime.InteropServices.Marshal.ReleaseComObject(oBook)
oBook = Nothing
System.Runtime.InteropServices.Marshal.ReleaseComObject(oBooks)
oBooks = Nothing
oExcel.Quit() <--**
System.Runtime.InteropServices.Marshal.ReleaseComObject(oExcel)
oExcel = Nothing
Comment