Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi All,
I was trying to create sheets from Book1 to Book2. And used this code Private oexcel As Excel.Application Dim oSourceWorkBooks_1 As Excel.Workbooks Dim oSourceWorkBook1 As Excel.Workbook Dim oDestinationWorkBooks_1 As Excel.Workbooks Dim oDestinationWorkBook_1 As Excel.Workbook Dim oSourceWorkSheets_1 As Excel.Sheets Dim oDataBaseSheet As Excel.Worksheet Dim oTemplateSheet As Excel.Worksheet Dim oDestinationWorkSheets_1 As Excel.Sheets Dim oDestinationWorkSheet_1 As Excel.Worksheet Sub New(ByVal file As String) Dim filename As String = Path.Combine(Path.GetTempPath, Path.GetTempFileName) Dim _filename As String = "" Dim b As Excel.Workbook oexcel = CreateObject("Excel.Application") oexcel.Visible = True oexcel.DisplayAlerts = False oDestinationWorkBooks_1 = oexcel.Workbooks oDestinationWorkBook_1 = oDestinationWorkBooks_1.Add oSourceWorkBooks_1 = oexcel.Workbooks oSourceWorkBook1 = oSourceWorkBooks_1.Open(file) oSourceWorkSheets_1 = oSourceWorkBook1.Sheets oTemplateSheet = oSourceWorkSheets_1("Template") oDataBaseSheet = oSourceWorkSheets_1("Database") oDestinationWorkSheets_1 = oDestinationWorkBook_1.Sheets oDestinationWorkSheet_1 = oDestinationWorkSheets_1("Sheet1") 'Copy sheets from Book1 to 2 For index As Integer = 1 To 10 oTemplateSheet.Copy(oDestinationWorkSheet_1) Next 'End With 'oSourceWorkBook1 = oSourceWorkBooks1.Open(file) marshal(oTemplateSheet) marshal(oDataBaseSheet) marshal(oSourceWorkSheets_1) oSourceWorkSheets_1 = Nothing oDataBaseSheet = Nothing oTemplateSheet = Nothing oSourceWorkBook1.Close() marshal(oSourceWorkBooks_1) marshal(oSourceWorkBook1) oDestinationWorkBooks_1.Close() marshal(oDestinationWorkBooks_1) marshal(oDestinationWorkBook_1) oexcel.Quit() marshal(oexcel) System.IO.File.Delete(filename) System.Runtime.InteropServices.Marshal.FinalReleas eComObject(oexcel) Private Sub marshal(ByVal o As Object) If Not o Is Nothing Then System.Runtime.InteropServices.Marshal.ReleaseComO bject(o) o = Nothing End If End Sub It was releasing correctly upto the marked . While I try to copy sheets from WorkBook1 to WorkBook2 it was not releasing after adding that copy method |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Task Manager (shut down a task if active) | Excel Programming | |||
Running an excel macro from the task manager | Excel Programming | |||
excel.exe is not terminating from task manager | Excel Programming | |||
Task Manager and Excel 2003 | Excel Discussion (Misc queries) | |||
EXCEL keeps running in task manager | Excel Programming |