Gruppe
Datei
Problem
Wie kann ich vor dem Öffnenbefehl feststellen, ob eine bestimmte Arbeitsmappe bereits geöffnet ist.
StandardModule: basMain
Function WkbExists(sFile As String) As Boolean
Dim wkb As Object
On Error Resume Next
Set wkb = Workbooks(sFile)
If Err = 0 And Not wkb Is Nothing Then
WkbExists = True
End If
On Error GoTo 0
End Function
Sub Aufruf()
Dim sFile As String
sFile = InputBox( _
prompt:="Dateiname:", _
Default:="Personl.xls")
If WkbExists(sFile) Then
MsgBox "Mappe ist offen!"
Else
MsgBox "Mappe ist geschlossen!"
End If
End Sub