Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default URGENT! Expunge Excel from Memory

Is there a fool proof way to expunge Excel from memory? I'm manipulating
Excel from Access 2003. Even when I use the following methods, I'm still
finding Excel.exe in Process in the Windows Task Manager:

Dim xlAppMst As Excel.Application
Dim xlBookMst As Excel.Workbook
Dim xlSheetMst As Excel.Worksheet

Set xlAppMst = CreateObject("Excel.Application")
Set xlBookMst = xlAppMst.Workbooks.Add
Set xlSheetMst = xlBookMst.Worksheets(1)

xlSheetMst.Visible = True
xlSheetMst.Cells.Select
Selection.NumberFormat = "@"

xlSheetMst.SaveAs fNameMst
......other code here

xlBookMst.Close
Set xlSheetMst = Nothing
Set xlBookMst = Nothing
xlAppMst.Quit
Set xlAppMst = Nothing

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default URGENT! Expunge Excel from Memory

It is very easy to leave "orphan" references when automating Excel that prevent
the application from quitting. One of the ways to create these is using
unqualified references such as "Selection", "ActiveWorkbook", and "ActiveSheet".
Use object references for all objects in Excel and Set them to nothing when exiting.

Also, you are changing the number format on 17 million cells.
You probably don't want to do that.

You can handle the selection and number format issue with something
like this...
Dim xlRangeMst as Excel.Range
Set xlRangeMst = xlSheetMst.Range("A1:F1000") 'you specify
xlRangeMst.NumberFormat = "@"
xlAppMst.Visible = True

'check the rest of your code for unqualified references
'also eliminate any use of "With".

Set xlRangeMst = Nothing
Set xlSheetMst = Nothing
xlBookMst.Close
Set xlBookMst = Nothing
xlAppMst.Quit
Set xlAppMst = Nothing
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Perico"
wrote in message
Is there a fool proof way to expunge Excel from memory? I'm manipulating
Excel from Access 2003. Even when I use the following methods, I'm still
finding Excel.exe in Process in the Windows Task Manager:

Dim xlAppMst As Excel.Application
Dim xlBookMst As Excel.Workbook
Dim xlSheetMst As Excel.Worksheet

Set xlAppMst = CreateObject("Excel.Application")
Set xlBookMst = xlAppMst.Workbooks.Add
Set xlSheetMst = xlBookMst.Worksheets(1)

xlSheetMst.Visible = True
xlSheetMst.Cells.Select
Selection.NumberFormat = "@"

xlSheetMst.SaveAs fNameMst
......other code here

xlBookMst.Close
Set xlSheetMst = Nothing
Set xlBookMst = Nothing
xlAppMst.Quit
Set xlAppMst = Nothing

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default URGENT! Expunge Excel from Memory

Make sure you qualify every reference to an object all the way down from the
xlAppMst object or an object that is derived from xlAppMst.
Then release the references in reverse order.

Make sure all references are release (your problem now - they all are not
released - possibly because you created a unqualified reference by refering
to an object without fully qualifying it.).

--
Regards,
Tom Ogilvy


"Perico" wrote in message
...
Is there a fool proof way to expunge Excel from memory? I'm manipulating
Excel from Access 2003. Even when I use the following methods, I'm still
finding Excel.exe in Process in the Windows Task Manager:

Dim xlAppMst As Excel.Application
Dim xlBookMst As Excel.Workbook
Dim xlSheetMst As Excel.Worksheet

Set xlAppMst = CreateObject("Excel.Application")
Set xlBookMst = xlAppMst.Workbooks.Add
Set xlSheetMst = xlBookMst.Worksheets(1)

xlSheetMst.Visible = True
xlSheetMst.Cells.Select
Selection.NumberFormat = "@"

xlSheetMst.SaveAs fNameMst
.....other code here

xlBookMst.Close
Set xlSheetMst = Nothing
Set xlBookMst = Nothing
xlAppMst.Quit
Set xlAppMst = Nothing



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default URGENT! Expunge Excel from Memory

These are great suggestions. Thank you both very much!

"Perico" wrote:

Is there a fool proof way to expunge Excel from memory? I'm manipulating
Excel from Access 2003. Even when I use the following methods, I'm still
finding Excel.exe in Process in the Windows Task Manager:

Dim xlAppMst As Excel.Application
Dim xlBookMst As Excel.Workbook
Dim xlSheetMst As Excel.Worksheet

Set xlAppMst = CreateObject("Excel.Application")
Set xlBookMst = xlAppMst.Workbooks.Add
Set xlSheetMst = xlBookMst.Worksheets(1)

xlSheetMst.Visible = True
xlSheetMst.Cells.Select
Selection.NumberFormat = "@"

xlSheetMst.SaveAs fNameMst
.....other code here

xlBookMst.Close
Set xlSheetMst = Nothing
Set xlBookMst = Nothing
xlAppMst.Quit
Set xlAppMst = Nothing

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
XL 2007 - Out of Memory - memory leak/bug? PCLIVE Excel Discussion (Misc queries) 0 March 23rd 09 03:31 PM
IME MODE FOR EXCEL 2007 (URGENT URGENT) Stella Wong Excel Discussion (Misc queries) 1 August 23rd 08 11:16 PM
Excel VB Out of Memory Annette Excel Discussion (Misc queries) 0 December 19th 07 07:29 PM
The instruction at "0x65255ac9" referenced memory at "0x00000008". The memory could not be read. Clikc OK to terminate etc Angus Comber[_2_] Excel Programming 1 November 7th 03 01:18 PM
URGENT - Visual Basic Out of Memory sgl[_2_] Excel Programming 3 September 26th 03 06:15 PM


All times are GMT +1. The time now is 12:44 AM.

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

About Us

"It's about Microsoft Excel"