|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Creating Worksheets from Existing Excel Instances in VB.NET?Hi everyone,
I use the following code whenever I export to Excel from VB.NET objExcel = New Excel.Application() objWorkBooks = objExcel.Workbooks objWorkBook = objWorkBooks.Add objWorkSheet = objExcel.ActiveWorkbook.ActiveSheet The problem is that every time I need to export, it results in creating a new instance of Excel in memory. Excel is a bit of a resource hog, and suffers from memory leaks. Is there a way to open another worksheet from an Excel process/instance that is already running if there is one? How would I do this? Thanks! If objExcel is nothing then
objExcel = New Excel.Application() End if Use that code and you won't generate a new Excel application every time. <lee***@hotmail.com> wrote in message Show quoteHide quote news:1146512847.906148.11950@j33g2000cwa.googlegroups.com... > Hi everyone, > > I use the following code whenever I export to Excel from VB.NET > > objExcel = New Excel.Application() > objWorkBooks = objExcel.Workbooks > objWorkBook = objWorkBooks.Add > objWorkSheet = objExcel.ActiveWorkbook.ActiveSheet > > The problem is that every time I need to export, it results in creating > a new instance of Excel in memory. Excel is a bit of a resource hog, > and suffers from memory leaks. Is there a way to open another > worksheet from an Excel process/instance that is already running if > there is one? > > How would I do this? > > Thanks! > objExcel is not a global variable and only accessible in this function.
If Excel is already opened manually by the user I would like to use that instance as well. Is there a way to attach to an existing process? +Vice wrote: Show quoteHide quote > If objExcel is nothing then > objExcel = New Excel.Application() > End if > > Use that code and you won't generate a new Excel application every time. > > <lee***@hotmail.com> wrote in message > news:1146512847.906148.11950@j33g2000cwa.googlegroups.com... > > Hi everyone, > > > > I use the following code whenever I export to Excel from VB.NET > > > > objExcel = New Excel.Application() > > objWorkBooks = objExcel.Workbooks > > objWorkBook = objWorkBooks.Add > > objWorkSheet = objExcel.ActiveWorkbook.ActiveSheet > > > > The problem is that every time I need to export, it results in creating > > a new instance of Excel in memory. Excel is a bit of a resource hog, > > and suffers from memory leaks. Is there a way to open another > > worksheet from an Excel process/instance that is already running if > > there is one? > > > > How would I do this? > > > > Thanks! > >
How about: How do I attach a file to an email w/MailTo: ?
hierachical related data in datatset Binding to an enumeration Access rights for a web application to read a text file on a different server strong reference between objects in different assemblies web reference to system.web.dll Converting VB Script Code to VB.NET 2005 SelectionChangeCommitted event TCP send & Recieve evaluate or transform or ??? |
|||||||||||||||||||||||