Das Archiv des Excel-Forums
Excel-Instanz wird nciht richtig beendet
Betrifft: Excel-Instanz wird nciht richtig beendet
von: Ulrich
Geschrieben am: 28.09.2003 12:08:28
Hallo,
ich habe folgenden Code (wird in einem word-Dokument aufgerufen):
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Set xlBook = Workbooks.Open("C:\liste.xls")
Set xlApp = xlBook.Parent
xlApp.Visible = False
xlApp.Windows(ActiveWorkbook.Name).Visible = True
Set xlSheet = xlBook.Sheets(ActiveSheet.Name)
'Hier wird in Word Text hinter Textmarken eingefügt. Das funktioniert
xlBook.Close False
xlApp.Quit
xlApp.Visible = True
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
Der Code funktioniert in so weit auch richtig. Mein Problem ist: Wenn ich dieses ablaufen lasse, zeigt mir der Windows Task Manager immer noch einen Prozess namens EXCEL.exe an. Das heißt, eine INstanz von Excel läuft noch. Nun ist meine Frage, wie bekomme ich das so hin, dass beim Beenden von Excel auch der Prozess sauber beendet wird? Wenn ich nämlich nach dem Ausführen dieses Skriptes Excel öffne, indem ich im Explorer eine Excel-Datei öffne, wird diese nicht richtig angezeigt.
Beste Grüße
Ulrich
Betrifft: AW: Excel-Instanz wird nciht richtig beendet
von: Hans W. Hofmann
Geschrieben am: 28.09.2003 12:38:54
Du hast da ein paar logische Brüche. Ich korrigiere das mal
Dim xlApp As New Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Set xlBook = xlApp.Workbooks.Open("C:\liste.xls")
Set xlSheet = xlBook.Sheets(1)
'Hier wird in Word Text hinter Textmarken eingefügt. Das funktioniert
xlBook.Close False
xlApp.Quit
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
So sollte das Dienst tun...
Gruß HW
Betrifft: AW: Excel-Instanz wird nciht richtig beendet
von: Ulrich
Geschrieben am: 28.09.2003 12:51:16
Hallo,
danke für Deine Antwort. Jetzt funktioniert es.
Beste Grüße
Ulrich