Creating new Excel object from VB .NET Class

G

Guest

I have a .NET VB class library application ClassLibrary1 that creates an
Excel object (Excel 2000 – 9.0 build 6926 SP-3) as below:

Public Class Class1
Dim app As New Excel.Application

Sub Main()
MsgBox("Hello!")
End Sub
End Class

And I have a VBScript application:

Dim cls
Set cls = CreateObject("ClassLibrary1.Class1")
cls.Main
msgbox "Hello from VBScript!"

The application displays “Hello!†and “Hello from VBScript!†in two separate
dialog boxes. However, after the script is run, in Task Manager there is a
copy of EXCEL.EXE in the Processes Tab. And there is a new copy of EXCEL.EXE
every time I run the script. If I remove the MsgBox("Hello!") from
ClassLibrary1, the copy of EXCEL.EXE in Task Manager is removed. Is there any
idea why this happens? And how I can have the MsgBox statement in
ClassLibrary1 without leaving an orphaned EXCEL.EXE process?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top