472,371 Members | 1,417 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,371 software developers and data experts.

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 2082
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: implicate_order | last post by:
Greetings, I'm new to python and am in the process of writing a script to parse some CSV data, spread it across multiple Excel worksheets and then generate charts. I searched the internet to...
1
by: Mitch | last post by:
I am using Access to create an Excel spreadsheets with graphs related to rows on the sheet1 to the graph on sheet2. I am using the same data but different subsets of the data to make different...
0
by: helraizer1 | last post by:
Hi folks, I have made a ledger sub in Excel. The task is to create a spreadsheet solution for a foreign exchange bureau so each transaction that happens it adds the details to a ledger sheet. ...
1
by: CoreyReynolds | last post by:
I can't find any information on this. If I have an existing query and I want to dump it into a page on a spread sheet and modify it as a pivot table all in VBA, can I do that? I only have the...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.