Bonjour le forum
Et longue vie à ce site
Pour classeur2:
Private Function EstDansCollection(Coln As Object, Item As String) As Boolean
Dim obj As Object
On Error Resume Next
Set obj = Coln(Item)
EstDansCollection = Not obj Is Nothing
End Function
Sub Macro1()
Dim Reponse
If EstDansCollection(Workbooks, 'Classeur2.xls') = True Then
MsgBox 'Le classeur 2 est déjà ouvert !'
Exit Sub
End If
If EstDansCollection(Workbooks, 'Classeur2.xls') = False Then
Reponse = MsgBox('Le classeur 2 n'est pas ouvert, voulez-vous l'ouvrir ?', vbInformation + vbYesNo)
If (Reponse = vbNo) Then
Exit Sub
Else
Workbooks.Open ('Classeur2.xls')
End If
End If
End Sub
A++
Temjeh