Bonjour,
J'ai utilisé l'enregistreur de macro afin d'obtenir un code permettant de protéger une cellule :
Cette macro fonctionne bien mais je me demandais si il n'y avait pas plus simple comme par exemple :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 sub ProtegeCellule rem ---------------------------------------------------------------------- rem define variables dim document as object dim dispatcher as object rem ---------------------------------------------------------------------- rem get access to the document document = ThisComponent.CurrentController.Frame dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") rem ---------------------------------------------------------------------- dim args1(0) as new com.sun.star.beans.PropertyValue args1(0).Name = "ToPoint" args1(0).Value = "$H$5" dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1()) rem ---------------------------------------------------------------------- dim args2(3) as new com.sun.star.beans.PropertyValue args2(0).Name = "Protection.Locked" args2(0).Value = true args2(1).Name = "Protection.FormulasHidden" args2(1).Value = true args2(2).Name = "Protection.Hidden" args2(2).Value = false args2(3).Name = "Protection.HiddenInPrintout" args2(3).Value = true dispatcher.executeDispatch(document, ".uno:Protection", "", 0, args2()) end sub
Par avance merci de votre aide.
Code : Sélectionner tout - Visualiser dans une fenêtre à part ofeuille.ocellule.protect = True
Bien sincèrement
Partager