Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Releasing Range Object

Hello,
I m new to Excel Programming, I was trying to Release the Range
Object that I got using the below code,

Excel.Range oRange; //Decl

oRange = (Excel.Range)m_oWorkSheet.Cells.Find(strSearchFor,
m_oWorkSheet.Cells[nHeaderRow, iter], Excel.XlFindLookIn.xlValues,
Excel.XlLookAt.xlWhole,
m_objOpt, Excel.XlSearchDirection.xlNext, false, m_objOpt, m_objOpt); //Get
Range Object

Marshal.ReleaseComObject(oRange); //Release Range Object

My Problem is when I get Range Object in the above specified way Excel
Instance keep running afte releasing other COM Object.

If I get it using below specified way Excel Instance is killed
at the end.
"oRange.get_Range(strStartRng, strStartRng)"

Is there any other way to release the Range Object?
Thanks in Advance.




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Releasing Range Object

Within Excel, the range is releaseable if it set to Nothing:

Sub dural()
Dim r As Range
Set r = Range("A1")
MsgBox (r.Address)
Set r = Nothing
End Sub
--
Gary''s Student - gsnu200825


"Kart" wrote:

Hello,
I m new to Excel Programming, I was trying to Release the Range
Object that I got using the below code,

Excel.Range oRange; //Decl

oRange = (Excel.Range)m_oWorkSheet.Cells.Find(strSearchFor,
m_oWorkSheet.Cells[nHeaderRow, iter], Excel.XlFindLookIn.xlValues,
Excel.XlLookAt.xlWhole,
m_objOpt, Excel.XlSearchDirection.xlNext, false, m_objOpt, m_objOpt); //Get
Range Object

Marshal.ReleaseComObject(oRange); //Release Range Object

My Problem is when I get Range Object in the above specified way Excel
Instance keep running afte releasing other COM Object.

If I get it using below specified way Excel Instance is killed
at the end.
"oRange.get_Range(strStartRng, strStartRng)"

Is there any other way to release the Range Object?
Thanks in Advance.




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
Releasing Outlook Candyman Excel Programming 0 March 31st 07 01:26 AM
Releasing reference to the Application object before exiting cgr Excel Programming 2 January 9th 06 10:45 PM
Releasing arrays? SiriS Excel Discussion (Misc queries) 3 December 19th 05 12:46 PM
returning pivottable object from a range object Grant Excel Programming 2 September 27th 04 02:22 AM
Range object to Array object conversion Tom Ogilvy Excel Programming 0 August 1st 03 12:16 AM


All times are GMT +1. The time now is 02:53 PM.

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"