469,899 Members | 1,460 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,899 developers. It's quick & easy.

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!

May 1 '06 #1
2 1983
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.

<le****@hotmail.com> wrote in message
news:11*********************@j33g2000cwa.googlegro ups.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!

May 2 '06 #2
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:
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.

<le****@hotmail.com> wrote in message
news:11*********************@j33g2000cwa.googlegro ups.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!


May 2 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.