ich benenne eine Datei per Makro um.
Wie bringe ich das Makro dazu mir ne Fehlermeldung zu geben wenn die *.csv Datei nicht vorhanden ist?
Option Explicit
Public Sub umbenennen_csv_Regio()
Dim objFSO As Object
Dim objDir As Object
On Error GoTo Fin
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objDir = objFSO.GetFolder(ThisWorkbook.Path & "\")
'dirInfo objDir, "*.csv", True ' Mit Unterordner
dirInfo objDir, "*.csv"
Fin:
Set objDir = Nothing
Set objFSO = Nothing
End Sub
Public Sub dirInfo(ByVal objCurrentDir As Object, ByVal strName As String, _
Optional ByVal blnTMP As Boolean = False)
Dim varTMP As Variant
Dim strNew As String
If varTMP = 0 Then MsgBox "Fehler": Exit Sub
For Each varTMP In objCurrentDir.Files
If varTMP.Name Like strName Then
strNew = "Regal1.csv"
Name varTMP.Path As varTMP.ParentFolder & "\" & strNew
End If
Next varTMP
If blnTMP = True Then
For Each varTMP In objCurrentDir.SubFolders
dirInfo varTMP, strName, True
Next varTMP
End If
Call Daten_importieren_BDV_Regio
End Sub