automation program closing ?

A

andreas

Hi,

Who can gives me a explanation for this

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim xlApp As New Excel.Application()

Dim sngLoon As Single

sngLoon = xlApp.WorksheetFunction.Pmt(0.09 / 12, 360, 150000)

TextBox1.Text = Format(Math.Abs(sngLoon), "c")

xlApp.Quit()

Dim myprocesses() As Process

Dim myprocess As Process

myprocesses = Process.GetProcessesByName("excel")

For Each myprocess In myprocesses

myprocess.CloseMainWindow()

Next

MsgBox(IsNothing(xlApp).ToString)

sngLoon = xlApp.WorksheetFunction.Pmt(0.09 / 12, 360, 1500)

TextBox1.Text = Format(Math.Abs(sngLoon), "c")

End Sub

xlapp must be closed with xlapp.quit and also with
....myprocess.closemainwindow ( or not ?)

the msgbox gives false and i have also a second calculation in the textbox

How is this possible and how can i close the program excel if it is not ?

Thanks for any response
 
H

Herfried K. Wagner [MVP]

* "andreas said:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim xlApp As New Excel.Application()

Dim sngLoon As Single

sngLoon = xlApp.WorksheetFunction.Pmt(0.09 / 12, 360, 150000)

TextBox1.Text = Format(Math.Abs(sngLoon), "c")

xlApp.Quit()

PRB: Office Application Does Not Quit After Automation from Visual Studio .NET Client
<http://support.microsoft.com/?scid=kb;en-us;317109>
 
A

andreas

Thanks Herfried for the information.
One have to install the PIAs

What i also find is that doing the follewing :

Private Sub Form1_Closing(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing

If Not IsNothing(xlprog) Then

xlprog.Quit()

xlprog = Nothing

End If

End Sub

gives a solution when leaving the vb.net program but this do not work in a
sub , right ?
 

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