Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Application Object

Status
Not open for further replies.

GSMike

Programmer
Feb 7, 2001
143
US
I am creating an Excel Application object by:
Code:
Dim xlApp as New Excel.Application, xlWkb as Excel.Workbook
In my error handler I have:
Code:
xlWkb.close false
xlApp.quit

When I step through the error handler, I watch the NT Task Manager. I notice that the xlApp.Quit code doesn't really do anything until I click the "Reset" button on the toolbar, even if the code is finished executing. In the "Processes" tab in NT Task Manager, that instance of Excel is still there.

Is there any way to kill the instance of Excel that is created by
Code:
Dim xlApp as New Excel.Application
via code, without having to reset the module???

Thanking you in advance, Mike K
 
I tried that and got an error message.
So then I tried
Code:
set xlapp=nothing.
I didn't get any error messages, but it also didn't have any effect on NT Task Manager.
Thanks for the suggestion. Mike K
 
Excel has this issue.

Thaere was a great thread on this but I can't seem to find it...

Have you tried removing the "New"?

Dim xlApp as New Excel.Application
Set xlApp = GetObject(,"Excel.Application")

I think if you do it this way it should work (but I've been wrong before) Kyle [pipe]
 
This is Microsoft's Example

Sub SendDataToXL()
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim ExcelRunning As Boolean

ExcelRunning = IsExcelRunning()
If Not ExcelRunning Then
Set xlApp = CreateObject("Excel.Application")
Else
Set xlApp = GetObject(, "Excel.Application")
End If

xlApp.Visible = True
Set xlBook = xlApp.Workbooks.Add()
xlBook.Worksheets(1).Cells(1, 1).Value = "Hello"
xlBook.SaveAs "C:\Book1.xls"

'If we started the instance, our code uses the
'Quit method to close the instance
If Not ExcelRunning Then xlApp.Quit
Set xlBook = Nothing
Set xlApp = Nothing

End Sub
 
That looks great. I had often wondered how to add a workbook to an already existing instance of Excel.
Question is, will it work for me.
I'll try it out and give you a report back.
Thanks for your help! Mike K
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top