OVH Cloud OVH Cloud

Flip/flop d'images dans une feuille protégée.

2 réponses
Avatar
BB
J'ai deux images superposées (1er plan/ arriére plan) et en fonction d'une
réponse j'affiche l'une ou l'autre. Mais comme je protège ma feuille, la
macro ne trouve plus le nom de mon image. Je tourne en rond.
Excel ne veut pas / ou ignore les protect/unprotect.
Autre solution?
Ci-dessous une partie du code:
If Cells(4, 4) <> 1 Then
ActiveSheet.Unprotect Password:="999", DrawingObjects:=True,
Contents:=True, Scenarios:=True
ActiveSheet.Shapes("Chris_o").Select
Selection.ShapeRange.ZOrder msoBringToBack
ActiveSheet.Shapes("Chris_s").Select
Selection.ShapeRange.ZOrder msoBringToFront
ActiveSheet.Protect Password:="999", DrawingObjects:=True,
Contents:=True, Scenarios:=True
i = MsgBox("If faut donner la bonne réponse", vbOKOnly,
"Cherchez encore")

Else
ActiveSheet.Protect Password:="999", DrawingObjects:=True,
Contents:=True, Scenarios:=True
ActiveSheet.Shapes("Chris_s").Select
Selection.ShapeRange.ZOrder msoBringToBack
ActiveSheet.Shapes("Chris_o").Select
Selection.ShapeRange.ZOrder msoBringToFront
ActiveSheet.Protect Password:="999", DrawingObjects:=True,
Contents:=True, Scenarios:=True
End If
--
C''était si facile avant...

2 réponses

Avatar
lSteph
Bonsoir,
As-tu essayé userinterfaceonly , par macro, de ne protèger que la partie
utilisateur et laisser agir le code?

Activesheet.protect Password:="999", userinterfaceonly:=true

'ainsi tu n'as plus besoin de déprotèger , reprotèger

lSteph


"BB" a écrit dans le message de news:

J'ai deux images superposées (1er plan/ arriére plan) et en fonction d'une
réponse j'affiche l'une ou l'autre. Mais comme je protège ma feuille, la
macro ne trouve plus le nom de mon image. Je tourne en rond.
Excel ne veut pas / ou ignore les protect/unprotect.
Autre solution?
Ci-dessous une partie du code:
If Cells(4, 4) <> 1 Then
ActiveSheet.Unprotect Password:="999",
DrawingObjects:=True,
Contents:=True, Scenarios:=True
ActiveSheet.Shapes("Chris_o").Select
Selection.ShapeRange.ZOrder msoBringToBack
ActiveSheet.Shapes("Chris_s").Select
Selection.ShapeRange.ZOrder msoBringToFront
ActiveSheet.Protect Password:="999", DrawingObjects:=True,
Contents:=True, Scenarios:=True
i = MsgBox("If faut donner la bonne réponse", vbOKOnly,
"Cherchez encore")

Else
ActiveSheet.Protect Password:="999", DrawingObjects:=True,
Contents:=True, Scenarios:=True
ActiveSheet.Shapes("Chris_s").Select
Selection.ShapeRange.ZOrder msoBringToBack
ActiveSheet.Shapes("Chris_o").Select
Selection.ShapeRange.ZOrder msoBringToFront
ActiveSheet.Protect Password:="999", DrawingObjects:=True,
Contents:=True, Scenarios:=True
End If
--
C''était si facile avant...


Avatar
BB
Merci ISteph,
J'ai avancé d'un grand pas. J'ai d'autres soucis mais je ferai une question
séparée.
@+

--
C''''était si facile avant...


"lSteph" wrote:

Bonsoir,
As-tu essayé userinterfaceonly , par macro, de ne protèger que la partie
utilisateur et laisser agir le code?

Activesheet.protect Password:="999", userinterfaceonly:=true

'ainsi tu n'as plus besoin de déprotèger , reprotèger

lSteph


"BB" a écrit dans le message de news:

J'ai deux images superposées (1er plan/ arriére plan) et en fonction d'une
réponse j'affiche l'une ou l'autre. Mais comme je protège ma feuille, la
macro ne trouve plus le nom de mon image. Je tourne en rond.
Excel ne veut pas / ou ignore les protect/unprotect.
Autre solution?
Ci-dessous une partie du code:
If Cells(4, 4) <> 1 Then
ActiveSheet.Unprotect Password:="999",
DrawingObjects:=True,
Contents:=True, Scenarios:=True
ActiveSheet.Shapes("Chris_o").Select
Selection.ShapeRange.ZOrder msoBringToBack
ActiveSheet.Shapes("Chris_s").Select
Selection.ShapeRange.ZOrder msoBringToFront
ActiveSheet.Protect Password:="999", DrawingObjects:=True,
Contents:=True, Scenarios:=True
i = MsgBox("If faut donner la bonne réponse", vbOKOnly,
"Cherchez encore")

Else
ActiveSheet.Protect Password:="999", DrawingObjects:=True,
Contents:=True, Scenarios:=True
ActiveSheet.Shapes("Chris_s").Select
Selection.ShapeRange.ZOrder msoBringToBack
ActiveSheet.Shapes("Chris_o").Select
Selection.ShapeRange.ZOrder msoBringToFront
ActiveSheet.Protect Password:="999", DrawingObjects:=True,
Contents:=True, Scenarios:=True
End If
--
C''était si facile avant...