Announcement

Collapse
No announcement yet.

Excel-prozesse bleiben offen, aber warum?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Excel-prozesse bleiben offen, aber warum?

    Nun habe ich schon so viel in den verschiednensten Foren gelesen, aber offensichtlich noch immer nicht verstanden. In meinem Programm öffne und schließe ich Excel, aber leider sind die Excel-Prozesse im Taskmanager noch offen. Warum??? Was mache ich falsch???

    Noch ein weiteres problem nervt mich:
    QxlBlatt = QxlMappe.Worksheets(1) führt im Programm zur Fehlermeldung:
    Aufruf wurde durch Aufgerufenen abgelehnt. (Ausnahme von HRESULT: 0x80010001 (RPC_E_CALL_REJECTED))
    Wenn ich das programm im Einzelschritt ausführe kommt es nicht zum Fehler. Warum???

    Hier nun mein Programm:

    Imports Microsoft.Win32
    Imports System.IO
    Imports System.Diagnostics
    Imports System.Threading

    Public Class Form1
    #Region "Variablen Deklaration"
    Dim Quelldatei As String
    Dim Zieldatei As String
    Dim Letztedatei As String
    Dim Jahr As Integer

    Dim QxlApp As Microsoft.Office.Interop.Excel.Application
    Dim QxlMappe As Microsoft.Office.Interop.Excel.Workbook
    Dim QxlBlatt As Microsoft.Office.Interop.Excel.Worksheet
    Dim QxlZelle As Microsoft.Office.Interop.Excel.Range

    Dim ZxlApp As Microsoft.Office.Interop.Excel.Application
    Dim ZxlMappe As Microsoft.Office.Interop.Excel.Workbook
    Dim ZxlBlattAE As Microsoft.Office.Interop.Excel.Worksheet
    Dim ZxlBlattUM As Microsoft.Office.Interop.Excel.Worksheet
    Dim ZxlZelleAE As Microsoft.Office.Interop.Excel.Range
    Dim ZxlZelleUM As Microsoft.Office.Interop.Excel.Range
    #End Region



    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Statusanzeige.Text = "Anwendung gestartet . . . "

    For Jahr = 2001 To 2020
    Quelldatei = Getpath() & "AE-Zahlen\Komplettdatenmaster.xls"

    If File.Exists(Quelldatei) = True Then
    'Die nächste SAP-Excel-Quelle wird geladen
    Statusanzeige.Text = " Import der SAP-Daten " & Jahr & " . . ."

    QxlApp = New Microsoft.Office.Interop.Excel.Application
    QxlMappe = QxlApp.Workbooks.Open(Quelldatei)
    QxlBlatt = QxlMappe.Worksheets(1)
    QxlZelle = QxlBlatt.Range("A1")

    'ZxlApp = New Microsoft.Office.Interop.Excel.Application
    'ZxlMappe = ZxlApp.Workbooks.Open(Zieldatei)
    'ZxlBlattAE = ZxlMappe.Worksheets(1)
    'ZxlZelleAE = ZxlBlattAE.Range("A1")
    'ZxlBlattUM = ZxlMappe.Worksheets(4)
    'ZxlZelleUM = ZxlBlattUM.Range("A1")


    'ZxlMappe.Save()
    'ZxlMappe.Close()
    'ZxlApp.Quit()
    'ZxlBlattAE = Nothing
    'ZxlZelleAE = Nothing
    'ZxlBlattUM = Nothing
    'ZxlZelleUM = Nothing
    'ZxlMappe = Nothing
    'ZxlApp = Nothing

    QxlMappe.Save()
    QxlMappe.Close()
    QxlApp.Quit()
    QxlZelle = Nothing
    QxlBlatt = Nothing
    QxlMappe = Nothing
    QxlApp = Nothing
    End If
    Next
    End Sub
Working...
X