Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

tester si un classeur est ouvert

3 réponses
Avatar
Hicham Oudrhiri
Hi
Je cherche une macro pour tester si in classeur x.xls par exemple est ouvert
ou pas et renvoi un msgbox en fonction de chaque situation
Merci de votre aide
H

3 réponses

Avatar
JB
Bonsoir,

Function est_ouvert(f)
témoin = False
For Each i In Workbooks 'on parcourt la collection des classeurs
If UCase(i.Name) = UCase(f) Then
témoin = True
End If
Next i
est_ouvert = témoin
End Function

=est_ouvert("x.xls")

If est_ouvert("x.xls") then

JB

On 12 mar, 18:51, "Hicham Oudrhiri" wrote:
Hi
Je cherche une macro pour tester si in classeur x.xls par exemple est ouv ert
ou pas et renvoi un msgbox en fonction de chaque situation
Merci de votre aide
H


Avatar
LSteph
Sub testouvert()
on error goto fin

Workbooks("x.xls").activate
msgbox "Et oui je suis là!"
exit sub
fin:
msgbox "Non , pas là!"
end sub

Hi
Je cherche une macro pour tester si in classeur x.xls par exemple est ouvert
ou pas et renvoi un msgbox en fonction de chaque situation
Merci de votre aide
H




Avatar
Hicham Oudrhiri
Merci à tous
H
"JB" a écrit dans le message de news:

Bonsoir,

Function est_ouvert(f)
témoin = False
For Each i In Workbooks 'on parcourt la collection des classeurs
If UCase(i.Name) = UCase(f) Then
témoin = True
End If
Next i
est_ouvert = témoin
End Function

=est_ouvert("x.xls")

If est_ouvert("x.xls") then

JB

On 12 mar, 18:51, "Hicham Oudrhiri" wrote:
Hi
Je cherche une macro pour tester si in classeur x.xls par exemple est
ouvert
ou pas et renvoi un msgbox en fonction de chaque situation
Merci de votre aide
H