AW: Compile error
10.08.2021 08:53:39
Dom
Hallo Luschi,
der Fehler trat auf wenn ich das Makro in meiner VBAProjekt (Personal.xlsb) gestartet habe.
In einem neunen Modul in einer Arbeitsmappe klappt es jetzt. Nur ich versteh noch nicht warum :)
Der Code:
Option Explicit
Private Declare PtrSafe Function MakeSureDirectoryPathExists Lib "imagehlp.dll" ( _
ByVal DirPath As String) As Long
Public Sub Ordner_erstellen_files_abspeicher()
Dim strPath As String
Dim strFile As String
Dim objWorkbook As Workbook
' Öffne das Downloadverzeichnis und wähle File aus, welches in den Ordner verschoben werden soll.
With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = False
.Title = "Bitte Report auswählen"
.InitialFileName = "C:\Users\dora101\Downloads\"
.FilterIndex = 2
If .Show Then strFile = .SelectedItems(1)
End With
If strFile vbNullString Then
strPath = Environ$("USERPROFILE") & "\NoC" & Format$(Date, "dd_mm_yy") & "\"
Call MakeSureDirectoryPathExists(strPath)
Set objWorkbook = Workbooks.Open(Filename:=strFile)
Call objWorkbook.SaveAs(Filename:=strPath & "01ProcessChanges", FileFormat:=xlOpenXMLWorkbook)
Set objWorkbook = Nothing
End If
' Öffne das Downloadverzeichnis und wähle File aus, welches in den Ordner verschoben werden soll.
With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = False
.Title = "Bitte Report auswählen"
.InitialFileName = "C:\Users\dora101\Downloads\"
.FilterIndex = 2
If .Show Then strFile = .SelectedItems(1)
End With
If strFile vbNullString Then
strPath = Environ$("USERPROFILE") & "\NoC" & Format$(Date, "dd_mm_yy") & "\"
Call MakeSureDirectoryPathExists(strPath)
Set objWorkbook = Workbooks.Open(Filename:=strFile)
Call objWorkbook.SaveAs(Filename:=strPath & "02ProcessCancellation", FileFormat:=xlOpenXMLWorkbook)
Set objWorkbook = Nothing
End If
' Öffne das Downloadverzeichnis und wähle File aus, welches in den Ordner verschoben werden soll.
With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = False
.Title = "Bitte Report auswählen"
.InitialFileName = "C:\Users\dora101\Downloads\"
.FilterIndex = 2
If .Show Then strFile = .SelectedItems(1)
End With
If strFile vbNullString Then
strPath = Environ$("USERPROFILE") & "\NoC" & Format$(Date, "dd_mm_yy") & "\"
Call MakeSureDirectoryPathExists(strPath)
Set objWorkbook = Workbooks.Open(Filename:=strFile)
Call objWorkbook.SaveAs(Filename:=strPath & "03DocumentChanges", FileFormat:=xlOpenXMLWorkbook)
Set objWorkbook = Nothing
End If
' Öffne das Downloadverzeichnis und wähle File aus, welches in den Ordner verschoben werden soll.
With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = False
.Title = "Bitte Report auswählen"
.InitialFileName = "C:\Users\dora101\Downloads\"
.FilterIndex = 2
If .Show Then strFile = .SelectedItems(1)
End With
If strFile vbNullString Then
strPath = Environ$("USERPROFILE") & "\NoC" & Format$(Date, "dd_mm_yy") & "\"
Call MakeSureDirectoryPathExists(strPath)
Set objWorkbook = Workbooks.Open(Filename:=strFile)
Call objWorkbook.SaveAs(Filename:=strPath & "04DocumentCancelled", FileFormat:=xlOpenXMLWorkbook)
Set objWorkbook = Nothing
End If
End Sub