![]() |
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. |
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. |
All times are GMT +1. The time now is 02:52 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com