Excel Aufruf Async

  • VB.NET
  • .NET (FX) 4.5–4.8

Es gibt 1 Antwort in diesem Thema. Der letzte Beitrag () ist von ErfinderDesRades.

    Excel Aufruf Async

    Hallo zusammen,

    ich stoße für etliche Dateien >500 aus einem Verzeichnis mittels einer Schleife folgendes Sub an.
    Das ganze gestaltet sich als sehr zeitintensiv.

    VB.NET-Quellcode

    1. Sub ExcelPrepare(FilePath As String, TranslateName As String)
    2. Dim xlApp As New Excel.Application
    3. Dim xlWorkBook As Excel.Workbook
    4. Dim xlWorkSheet As Excel.Worksheet
    5. Dim Translation() As String = TranslateName.Split(CChar(";"))
    6. Dim TranslationPair() As String
    7. Dim i As Integer
    8. Dim ii As Integer
    9. xlWorkBook = xlApp.Workbooks.Open(FilePath)
    10. xlWorkSheet = CType(xlWorkBook.Sheets(1), Excel.Worksheet)
    11. Dim suchbereich As Excel.Range = CType(xlWorkSheet.Rows(1), Excel.Range)
    12. With xlWorkSheet
    13. .Range(2 & ":" & 2).Delete()
    14. For i = 0 To Translation.Length - 1
    15. TranslationPair = Translation(i).Split(CChar(":"))
    16. For ii = 0 To TranslationPair.Length - 1
    17. Dim c As Excel.Range
    18. Dim firstAddress As String
    19. With xlWorkSheet.Range("1:1")
    20. c = .Find(TranslationPair(0), LookIn:=Excel.XlFindLookIn.xlValues)
    21. If c IsNot Nothing Then
    22. firstAddress = c.Address
    23. Else
    24. firstAddress = Nothing
    25. End If
    26. End With
    27. If firstAddress <> Nothing Then
    28. .Range(firstAddress).Value = TranslationPair(1)
    29. End If
    30. Next ii
    31. Next i
    32. End With
    33. xlWorkBook.Close(SaveChanges:=True)
    34. End Sub


    Besteht die Möglichkeit dies mittels Async und Await aufzurufen?
    Und lässt sich dann ermitteln wenn alle Hintergrundprozesse abgeschlossen sind?

    Mit den Beispielen bzw. der Doku auf Docs bin ich nicht weitergekommen.

    Vielen Dank.

    Daniel