|
Set xLApp = CreateObject("Excel.Application")
Author |
Message |
08002g #1 / 3
|
 Set xLApp = CreateObject("Excel.Application")
I am using the code below to open an excel file, input and retreive data. The problem I have is that the Excel app is staying in the system memory. I know this because win2000 task manager shows it still running. I have another code that opens the same file and prints a sheet then closes it. That works OK and releases it from memory. Does anyone have any ideas? (prgResults is a progress bar) prgResults.Value = 0 prgResults.Visible = True On Error GoTo 0 Set xLApp = CreateObject("Excel.Application") prgResults.Value = 4 xLApp.Visible = True prgResults.Value = 7 xLApp.Application.Workbooks.Open App.Path & "\Tcomp.xls", password:="naComp" prgResults.Value = 10 xLApp.Range("Peak").Value = txtPeak prgResults.Value = 15 xLApp.Range("Mins").Value = txtMins prgResults.Value = 20 xLApp.Range("Qty").Value = CmbQty prgResults.Value = 25 xLApp.Range("Or2").Value = txtOr2 prgResults.Value = 30 xLApp.Range("OffNet").Value = txtOrON prgResults.Value = 35 xLApp.Range("OffOr").Value = txtOrOr prgResults.Value = 40 xLApp.Range("OffO").Value = txtOr prgResults.Value = 45 xLApp.Range("Item").Value = chkItem prgResults.Value = 50 xLApp.Range("DD").Value = chkDD prgResults.Value = 60 xLApp.Range("Ins").Value = chkIns prgResults.Value = 70 xLApp.Application.Worksheets("Result").Activate prgResults.Value = 85 xLApp.Range("B4:F11").Select xLApp.Selection.Sort Key1:=Range("F4"), Order1:=xlAscending, Header:=xlNo, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom xLApp.Range("Results").Select xLApp.Selection.Copy prgResults.Value = 90 OLEResults.Paste prgResults.Value = 100 Clipboard.Clear prgResults.Visible = False xLApp.ActiveWorkbook.Close SaveChanges:=xlDoNotSaveChanges xLApp.Quit Set xLApp = Nothing
|
Sat, 06 Mar 2004 10:00:37 GMT |
|
 |
N Lawto #2 / 3
|
 Set xLApp = CreateObject("Excel.Application")
Vexing little problem this one isn't it? Try using xLApp.UserControl = False immediately prior to the xLApp.Quit method
Quote: > I am using the code below to open an excel file, input and retreive data. > The problem I have is that the Excel app is staying in the system memory. I > know this because win2000 task manager shows it still running. I have > another code that opens the same file and prints a sheet then closes it. > That works OK and releases it from memory. > Does anyone have any ideas? > (prgResults is a progress bar) > prgResults.Value = 0 > prgResults.Visible = True > On Error GoTo 0 > Set xLApp = CreateObject("Excel.Application") > prgResults.Value = 4 > xLApp.Visible = True > prgResults.Value = 7 > xLApp.Application.Workbooks.Open App.Path & "\Tcomp.xls", > password:="naComp" > prgResults.Value = 10 > xLApp.Range("Peak").Value = txtPeak > prgResults.Value = 15 > xLApp.Range("Mins").Value = txtMins > prgResults.Value = 20 > xLApp.Range("Qty").Value = CmbQty > prgResults.Value = 25 > xLApp.Range("Or2").Value = txtOr2 > prgResults.Value = 30 > xLApp.Range("OffNet").Value = txtOrON > prgResults.Value = 35 > xLApp.Range("OffOr").Value = txtOrOr > prgResults.Value = 40 > xLApp.Range("OffO").Value = txtOr > prgResults.Value = 45 > xLApp.Range("Item").Value = chkItem > prgResults.Value = 50 > xLApp.Range("DD").Value = chkDD > prgResults.Value = 60 > xLApp.Range("Ins").Value = chkIns > prgResults.Value = 70 > xLApp.Application.Worksheets("Result").Activate > prgResults.Value = 85 > xLApp.Range("B4:F11").Select > xLApp.Selection.Sort Key1:=Range("F4"), Order1:=xlAscending, Header:=xlNo, > _ > OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom > xLApp.Range("Results").Select > xLApp.Selection.Copy > prgResults.Value = 90 > OLEResults.Paste > prgResults.Value = 100 > Clipboard.Clear > prgResults.Visible = False > xLApp.ActiveWorkbook.Close SaveChanges:=xlDoNotSaveChanges > xLApp.Quit > Set xLApp = Nothing
|
Sat, 06 Mar 2004 15:41:38 GMT |
|
 |
08002g #3 / 3
|
 Set xLApp = CreateObject("Excel.Application")
Thanks for the tip but there is no luck here, the app still shows as active in Task manager. One thing I have found out is that if I remove the Sort code the app releases OK. Do you have any ideas.
Quote: > Vexing little problem this one isn't it? > Try using > xLApp.UserControl = False > immediately prior to the > xLApp.Quit > method
> > I am using the code below to open an excel file, input and retreive data. > > The problem I have is that the Excel app is staying in the system memory. > I > > know this because win2000 task manager shows it still running. I have > > another code that opens the same file and prints a sheet then closes it. > > That works OK and releases it from memory. > > Does anyone have any ideas? > > (prgResults is a progress bar) > > prgResults.Value = 0 > > prgResults.Visible = True > > On Error GoTo 0 > > Set xLApp = CreateObject("Excel.Application") > > prgResults.Value = 4 > > xLApp.Visible = True > > prgResults.Value = 7 > > xLApp.Application.Workbooks.Open App.Path & "\Tcomp.xls", > > password:="naComp" > > prgResults.Value = 10 > > xLApp.Range("Peak").Value = txtPeak > > prgResults.Value = 15 > > xLApp.Range("Mins").Value = txtMins > > prgResults.Value = 20 > > xLApp.Range("Qty").Value = CmbQty > > prgResults.Value = 25 > > xLApp.Range("Or2").Value = txtOr2 > > prgResults.Value = 30 > > xLApp.Range("OffNet").Value = txtOrON > > prgResults.Value = 35 > > xLApp.Range("OffOr").Value = txtOrOr > > prgResults.Value = 40 > > xLApp.Range("OffO").Value = txtOr > > prgResults.Value = 45 > > xLApp.Range("Item").Value = chkItem > > prgResults.Value = 50 > > xLApp.Range("DD").Value = chkDD > > prgResults.Value = 60 > > xLApp.Range("Ins").Value = chkIns > > prgResults.Value = 70 > > xLApp.Application.Worksheets("Result").Activate > > prgResults.Value = 85 > > xLApp.Range("B4:F11").Select > > xLApp.Selection.Sort Key1:=Range("F4"), Order1:=xlAscending, > Header:=xlNo, > > _ > > OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom > > xLApp.Range("Results").Select > > xLApp.Selection.Copy > > prgResults.Value = 90 > > OLEResults.Paste > > prgResults.Value = 100 > > Clipboard.Clear > > prgResults.Visible = False > > xLApp.ActiveWorkbook.Close SaveChanges:=xlDoNotSaveChanges > > xLApp.Quit > > Set xLApp = Nothing
|
Sun, 07 Mar 2004 12:21:32 GMT |
|
|
|