Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Excel Object Not releasing from Task Manager (Vb.net)

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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Task Manager (shut down a task if active) Brettjg Excel Programming 2 February 21st 09 04:01 AM
Running an excel macro from the task manager OlieH Excel Programming 2 October 8th 07 03:46 AM
excel.exe is not terminating from task manager Inthi Excel Programming 0 November 28th 05 01:39 PM
Task Manager and Excel 2003 Mike Excel Discussion (Misc queries) 1 April 20th 05 10:40 PM
EXCEL keeps running in task manager Sam Excel Programming 4 January 22nd 04 11:17 AM


All times are GMT +1. The time now is 11:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"