Hi,
ich schlage mich momentan mit einem Automation Problem herum:
Szenario:
Access VBA - Hauptanwendung
Steuere Excel aus Access über Automation
Import von Daten weitesmöglich automatisieren, da ich die Standardfunktionen von Access unbefriedigend finde.
Problem:
Nach dem Import bleibt auf dem Rechner eines Anwneders immer eine Instanz von Excel im Taskmanager unter Prozesse im Hintergrund geöffnet, obwohl ich eigentlich sicherstelle, dass alle globalen Referenzen auf die Instanz auf Nothing gesetzt werden.
Damit dürfte für Excel eigentlich kein Grund mehr bestehen die Anwendung, die aus Access gestartet wurde im Hintergrund für eine möglich Automation vorzuhalten. Ich habe ja alle Referenzen geschlossen.
Noch komischer: Auf meinem Client läuft alles wunderbar. Ob Excel vorher lief oder nicht - egal. Die Anwendung wird völlig korrekt behandelt und bleibt nur geöffnet, wenn sie zuvor auch geöffnet war. Nur beim Anwender klappt es wieder nicht
.
Hoffe mir kann jemand helfen.
Vielen Dank - Uuudellelliiieeee ich hasse VBA!
ich schlage mich momentan mit einem Automation Problem herum:
Szenario:
Access VBA - Hauptanwendung
Steuere Excel aus Access über Automation
Import von Daten weitesmöglich automatisieren, da ich die Standardfunktionen von Access unbefriedigend finde.
Problem:
Nach dem Import bleibt auf dem Rechner eines Anwneders immer eine Instanz von Excel im Taskmanager unter Prozesse im Hintergrund geöffnet, obwohl ich eigentlich sicherstelle, dass alle globalen Referenzen auf die Instanz auf Nothing gesetzt werden.
Damit dürfte für Excel eigentlich kein Grund mehr bestehen die Anwendung, die aus Access gestartet wurde im Hintergrund für eine möglich Automation vorzuhalten. Ich habe ja alle Referenzen geschlossen.
Noch komischer: Auf meinem Client läuft alles wunderbar. Ob Excel vorher lief oder nicht - egal. Die Anwendung wird völlig korrekt behandelt und bleibt nur geöffnet, wenn sie zuvor auch geöffnet war. Nur beim Anwender klappt es wieder nicht


Code:
Private Sub Class_Terminate()
Call endExcel
End Sub
Private Sub Class_Initialize()
Call getExcelReference
xlsApp.visible = True
xlsApp.ScreenUpdating = False
Set xlsBook = New VBA.Collection
Set parStartCell = New VBA.Collection
Set xlsChart = New Scripting.Dictionary
Set openBook = New VBA.Collection
End Sub
Private Function endExcel()
Dim book As Object
'On Error GoTo Error_Handler:
terminationConfirmed = True
For i = 1 To xlsBook.count
xlsApp.workbooks(xlsBook.Item(i).name).Close False
Call xlsBook.Remove(i)
Next i
Set xlsBook = Nothing
Set parStartCell = Nothing
Set ws = Nothing
Set openBook = Nothing
Set eventBook = Nothing
Set xlsChart = Nothing
If xlWasOpen = False Then
xlsApp.Application.DisplayAlerts = False
xlsApp.Application.Quit
Else
xlsApp.Application.visible = True
xlsApp.Application.ScreenUpdating = True
For Each book In xlsApp.workbooks
If book.Windows(1).visible = False Then
book.Windows(1).visible = True
End If
Next book
Set book = Nothing
End If
Set xlsApp = Nothing
Exit Function
Error_Handler:
Debug.Print Err.Number
End Function
Private Sub getExcelReference()
' try to get excel application reference
On Error GoTo START_EXCEL
' if excel is running already, a reference is set
Set xlsApp = GetObject(, "Excel.application")
xlWasOpen = True
Exit Sub
START_EXCEL:
xlWasOpen = False
' excel is not running
' start excel
'Debug.Print err.Description
Set xlsApp = CreateObject("Excel.application")
End Sub
Hoffe mir kann jemand helfen.
Vielen Dank - Uuudellelliiieeee ich hasse VBA!