Hallo zusammen,
ich habe folgenden VBA Code um eine Ablage in Excel einzulesen. Leier klappt dieser nicht aus einer MAC Umgebung, und ich komme da auch nicht genau dahinter warum nicht. Könntet Ihr mir dazu bitte Hilfe leisten. Der Speicherort liegt auf einem NAS und ist per WEBDAV eingebunden.
Translation:
Hello everyone,
I have the following VBA code to read a sheet in Excel. But this does not work from a MAC environment, and I can't exactly figure out why not. Could you please help me with this. The storage location is located on a NAS and is integrated via WEBDAV.
HTML Code:
Sub DatenHolen_neu()
Dim i As Long, lngZ As Long
Dim strCurPath As String
Dim strNewPath As String
Dim varDateien As Variant
Dim wsZiel As Worksheet
strCurPath = CurDir
strNewPath = "X:\02_Berichtwesen\Berichte_aktuell\Berichte 2025"
ChDrive strNewPath
ChDir strNewPath
varDateien = Application.GetOpenFilename("Excel Files (*.xls*), *.xls*", , , , True)
ChDrive strCurPath
ChDir strCurPath
If IsArray(varDateien) Then
' Wenn das Makro in der Zieldatei steht, kann die Datei ThisWorkbook genannt werden.
Set wsZiel = ThisWorkbook.Sheets("Alle_Einsätze")
lngZ = wsZiel.Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To UBound(varDateien)
With Workbooks.Open(varDateien(i), , True).Worksheets("Bericht1")
' Cells wird wie folgt verwendet Cells(Zeilennummer, Spaltennummer)
' Die erste Zahl in der Klammer zeigt die Zeile, die zweite die Spalte
wsZiel.Cells(lngZ + i, 1) = .Cells(5, 45)
wsZiel.Cells(lngZ + i, 2) = .Cells(5, 36)
wsZiel.Cells(lngZ + i, 3) = .Cells(27, 34)
wsZiel.Cells(lngZ + i, 4) = .Cells(12, 39)
wsZiel.Cells(lngZ + i, 6) = .Cells(12, 44)
wsZiel.Cells(lngZ + i, 7) = .Cells(17, 44)
wsZiel.Cells(lngZ + i, 9) = .Cells(30, 20)
wsZiel.Cells(lngZ + i, 10) = .Cells(56, 12)
wsZiel.Cells(lngZ + i, 11) = .Cells(56, 14)
wsZiel.Cells(lngZ + i, 12) = .Cells(56, 16)
wsZiel.Cells(lngZ + i, 13) = .Cells(57, 12)
wsZiel.Cells(lngZ + i, 14) = .Cells(10, 7)
wsZiel.Cells(lngZ + i, 15) = .Cells(10, 35)
' Datei schließen, ohne Änderungen zu speichern
.Parent.Close False
End With
Next i
End If
End Sub
Wenn Ihr weitere Angaben benötigt einfach Fragen.
Liebe Grüße und vielen Dank
Translation:
If you need more information, just ask.
Best regards and thank you
Thomas