LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default multiple instances of excel process gets created in the task manager

Hello
I am sharing the code to open an excel workbook, but when i am
executing the code after MESSAGE BOX 2, multiple instances of excel
process gets created in the task manager and the excel application
hangs. kindly help

MessageBox.Show("1");
Excel.Application excelApp = new Excel.ApplicationClass
(); // Creates a new Excel Application
//excelApp.Visible = false; // Makes Excel visible to
the
user.


// The following line adds a new workbook
//Excel.Workbook newWorkbook = excelApp.Workbooks.Add
(Microsoft.Office.Interop.Excel.XlWBATemplate.xlWB ATWorksheet);


// The following code opens an existing workbook
MessageBox.Show("2");
Excel.Workbook _book;
string workbookPath = @"D:\Window Crawler\GenPatchReport
\Test Data\Data.xls"; // Add your own path here
_book = OpenExcelWorkbook(workbookPath);


//Excel.Workbook excelWorkbook = excelApp.Workbooks.Open
(workbookPath, Type.Missing, Type.Missing, Type.Missing,
Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing);


MessageBox.Show("3");


Excel.Sheets excelSheets = _book.Worksheets;
string currentSheet = "Sheet1";
Excel.Worksheet excelWorksheet =(Excel.Worksheet)
excelSheets.get_Item(currentSheet);


MessageBox.Show("4");


Excel.Range excelCell =(Excel.Range)
excelWorksheet.get_Range("A1", "A13");
excelCell.Delete(Type.Missing);
NAR(excelWorksheet);


MessageBox.Show("5");


protected Excel.Workbook OpenExcelWorkbook(string fileName)
{


try
{
if (ExcelApp != null)
{
Excel.Workbook wb;
//wb = ExcelApp.Workbooks.Open(fileName,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing);
wb = ExcelApp.Workbooks.Open(fileName,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing);
if (wb != null)
{
_sheets = wb.Worksheets;
}
return wb;


}
return null;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
return null;
}
}


private void NAR(object o)
{
try
{

System.Runtime.InteropServices.Marshal.ReleaseComO bject
(o);
}
catch { }
finally
{
o = null;
}
}


Thanks
Shantanu
 
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
Process will not end from task manager after vba code is over [email protected] Excel Programming 5 November 8th 06 06:24 PM
Printing leaves EXCEL.EXE process in Task Manager eeidfn Excel Discussion (Misc queries) 1 February 28th 06 02:24 AM
excel.exe is not terminating from task manager Inthi Excel Programming 0 November 28th 05 01:39 PM
Multiple Instances of Excel in WinXP Pro Task Manager Jorge Herrera Excel Programming 1 January 29th 04 06:39 PM
EXCEL keeps running in task manager Sam Excel Programming 4 January 22nd 04 11:17 AM


All times are GMT +1. The time now is 10:19 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"