HERBERS
Excel-Forum
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Excel-Instanz wird nciht richtig beendet

Excel-Instanz wird nciht richtig beendet
28.09.2003 12:08:28
Ulrich
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

2
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Benutzer
AW: Excel-Instanz wird nciht richtig beendet
28.09.2003 12:38:54
Hans W. Hofmann
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
AW: Excel-Instanz wird nciht richtig beendet
28.09.2003 12:51:16
Ulrich
Hallo,

danke für Deine Antwort. Jetzt funktioniert es.

Beste Grüße
Ulrich

Meistgelesene Forumthreads (12 Monate)