Buongiorno a tutti,
scusatemi ma so che più volte è stato affrontato questo argomento, ma ogni soluzione seguita non mi ha risolto l'anomalia.
Non riesco a chiudere il processo di Excel con VB.net 2008
codice:Imports System.Threading Public Class Form1 : Inherits Form Dim Trasferisci As Threading.Thread Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim Trasferisci As New Threading.Thread(AddressOf trasferisciSSC) Trasferisci.Start() End Sub Private Sub trasferisciSSC() Dim oExcel As New Object oExcel = CreateObject("Excel.Application") Dim oBook As Object oBook = oExcel.Workbooks.Open("...\Test Kill Excel.xlsx") Dim osheet0 As Object osheet0 = oBook.Worksheets(1) osheet0.Activate() osheet0.Cells(1, 1).value = TextBox1.Text oBook.Close(SaveChanges:=True) osheet0 = Nothing oBook = Nothing oExcel = Nothing End Sub End Class
Provando ad escludere i le varie operazioni sono arrivato a questo:
Anche solo creando un nuovo processo , già non riesce a chiuderlo...codice:Imports System.Threading Public Class Form1 : Inherits Form Dim Trasferisci As Threading.Thread Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim Trasferisci As New Threading.Thread(AddressOf trasferisciSSC) Trasferisci.Start() End Sub Private Sub trasferisciSSC() Dim oExcel As New Object oExcel = CreateObject("Excel.Application") oExcel = Nothing End Sub End Class
Cosa non distruggo correttamente?
Fino ad oggi ho utilizzato un KILL Excell, ma come ben sapete mi "killa" tutti processi presenti.

Rispondi quotando
