Botón para bloquear/desbloquear libro excel

Hola expertos... Pues eso, se puede hacer un botón para desbloquear/bloquear un libro de excel?.

Agradezco su ayuda.

Gracias.

Respuesta
1

Inserta un botón de alternar (Toggle Button), cámbiale el nombre a tgbDesbloquear y asígnale el siguiente código a su evento CHANGE:

Private Sub tgbDesbloquear_Change()
If ActiveWorkbook.ProtectStructure = True Or ActiveWorkbook.ProtectWindows = True Then
ActiveWorkbook.Unprotect ("1234")
ActiveSheet.Range("a1").Value = "Libro Bloqueado: " & ActiveWorkbook.ProtectStructure
tgbDesbloquear.Caption = "Bloquear Libro"
Else
ActiveWorkbook.Protect Structure:=True, Windows:=True, Password:="1234"
ActiveSheet.Range("a1").Value = "Libro Bloqueado: " & ActiveWorkbook.ProtectStructure
tgbDesbloquear.Caption = "Desbloquear Libro"
End If
End Sub

Que tengas un EXCELente fin de semana.

Jorge A. Rodríguez Lopera

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas