ThisWorkbook.Path
kannst Du prüfen, ob sich die Datei dort befindet.
Option Explicit
Sub test()
If ThisWorkbook.Path "C:\Users\Franz\OneDrive\Desktop" Then
MsgBox "Falscher Pfad!", vbCritical, "!"
Application.DisplayAlerts = False
ThisWorkbook.Close False
End If
End Sub
Servus
Option Explicit
Private Sub Workbook_Open()
If ThisWorkbook.Path Environ("Userprofile") & "\Desktop" Then
MsgBox "Falscher Pfad!", vbCritical, "!"
Application.DisplayAlerts = False
ThisWorkbook.Close False
End If
End Sub
Peter
if thisworkbook.path = environ("userprofile") &"\desktop" then
'alles gut
else
close false
end if
Gruß