I cant take it..
I have found countless messages on countless boards, even an article on microsofts site..however I CANNOT MAKE IT WORK.
Here is the deal, i have a very heft sub that builds an excel spreadsheet from a template.
everything works dandy, however EXCEL.EXE WONT RELEASE..even though the rest works fine.
however, there is one and only one time i can make the dam excel release..
Now, another ex., where it dosnt work
not only that, if i just call the new excel.application line, then skip down to where it kills the references to the objects, it will not release..EXCEL.EXE STAYS IN THE TASK MANAGER UNDER PROCESSES....
http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q317109
I tried the above link ..DAM somoene help me out of my misery!
THANKS!
[/code]
I have found countless messages on countless boards, even an article on microsofts site..however I CANNOT MAKE IT WORK.
Here is the deal, i have a very heft sub that builds an excel spreadsheet from a template.
everything works dandy, however EXCEL.EXE WONT RELEASE..even though the rest works fine.
however, there is one and only one time i can make the dam excel release..
Code:
Public Sub excelimp()
Dim MyExcel As New Excel.Application()
MyExcel.Quit()
MyExcel = Nothing
NARS(MyExcel)
GC.Collect()
GC.WaitForPendingFinalizers()
Exit Sub
AT THIS POINT, IT RELEASES FINE
Dim mc As New iContract(MSa)
Dim contype As Int32
Dim a As Int16
Dim y As Int16
Dim z As Int16
mc.SQLCmdText = "Select notes,mfgr,model,descr,qty,hrs,list,sell,unitcost,extcost,mrkup,disclvl,ptype,idnum from msales where sanum = " & MSa & " AND jobnum = " & cmboJob.Text & " AND altnum = " & cmboAlt.Text
Dim SQLdap As New SqlClient.SqlDataAdapter(mc.SQLCmdText, mc.SQLConnection)
Dim SQLtbl As New DataTable()
etc
Now, another ex., where it dosnt work
Code:
Public Sub excelimp()
Dim MyExcel As New Excel.Application()
Dim mc As New iContract(MSa)
Dim contype As Int32
Dim a As Int16
Dim y As Int16
Dim z As Int16
mc.SQLCmdText = "Select notes,mfgr,model,descr,qty,hrs,list,sell,unitcost,extcost,mrkup,disclvl,ptype,idnum from msales where sanum = " & MSa & " AND jobnum = " & cmboJob.Text & " AND altnum = " & cmboAlt.Text
Dim SQLdap As New SqlClient.SqlDataAdapter(mc.SQLCmdText, mc.SQLConnection)
Dim SQLtbl As New DataTable()
SQLdap.Fill(SQLtbl)
contype = mc.ContractType
With mc
.ProcedureName = "sp_GetFolderFile"
.ClearParameter()
.ClearParameterVal()
.sp_DocAll()
.AddParameterVal(MSa.ToString)
.AddParameterVal(cmboJob.Text)
.AddParameterVal(cmboAlt.Text)
.AddParameterVal(cmboRev.Text)
.SQLConnection.Open()
.InitProcedure()
.SQLReader = Nothing
.SQLReader = .SQLCmd.ExecuteReader(CommandBehavior.Default)
.SQLReader.Read()
FileCopy(ExcelTemplatePath, FullPath & Convert.ToString(.SQLReader.Item(0)) & "\" & Convert.ToString(.SQLReader.Item(1)) & ".xls")
test = FullPath & Convert.ToString(.SQLReader.Item(0)) & "\" & Convert.ToString(.SQLReader.Item(1)) & ".xls"
Dim oWorkBooks As Excel.Workbooks = MyExcel.Workbooks
Dim OWorkBook As Excel.Workbook = oWorkBooks.Add
Dim oSheet As Excel.Worksheet = MyExcel.ActiveSheet
MyExcel.Workbooks.Open(FullPath & Convert.ToString(.SQLReader.Item(0)) & "\" & Convert.ToString(.SQLReader.Item(1)) & ".xls")
y = 4
z = 4
NARS(oSheet)
OWorkBook.Close()
NARS(OWorkBook)
NARS(oWorkBooks)
MyExcel.Quit()
MyExcel = Nothing
NARS(MyExcel)
GC.Collect()
GC.WaitForPendingFinalizers()
Exit Sub
IT WILL NOT RELEASE HERE..WHY! EVEN IF I SKIP ALL OTHER CODE AFTER I INIT THE EXCEL OBJECTS, IT WON"T GO!
not only that, if i just call the new excel.application line, then skip down to where it kills the references to the objects, it will not release..EXCEL.EXE STAYS IN THE TASK MANAGER UNDER PROCESSES....
http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q317109
I tried the above link ..DAM somoene help me out of my misery!
THANKS!
[/code]