- ©«¤l
- 5923
- ¥DÃD
- 13
- ºëµØ
- 1
- ¿n¤À
- 5986
- ÂI¦W
- 0
- §@·~¨t²Î
- win10
- ³nÅ骩¥»
- Office 2010
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW°ò¶©
- µù¥U®É¶¡
- 2010-5-1
- ³Ì«áµn¿ý
- 2022-1-23
        
|
¦^´_ 19# ©P¤j°¶
1.±Nµ{¦¡½X¶K©ó ThisWorkbook, ±M®×ªºÄÝ©Ê->«OÅ@ ¤Ä¿ïÂê©w±M®×, ¿é¤J±K½X
2.¬¡¶Ã¯¥t¦sÀɮ׫ü¥O -> ¤u¨ã-> ¤@¯ë¿ï¶µ ¿é¤J¬¡¶Ã¯«OÅ@±K½X- Option Explicit
- Private Const ±K½X = "1234"
- Private Const ¦rÅéÃC¦â = 1
- Private Const «OÅ@¦â = 2 '¥i¦Û¦æקï
- Dim Answer$
- Private Sub Workbook_Open()
- Sheets_Protect
- Answer_Pass
- End Sub
- Private Sub Workbook_BeforeClose(Cancel As Boolean)
- Sheets_Protect
- Save
- End Sub
- Private Sub Workbook_SheetActivate(ByVal Sh As Object)
- Answer_Pass
- End Sub
- Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
- My_UnProtect (IIf(Answer = ±K½X, True, False))
- End Sub
- Private Sub Sheets_Protect()
- Dim Sh As Worksheet
- For Each Sh In Sheets
- With Sh
- .Unprotect ±K½X
- .Cells.Font.ColorIndex = «OÅ@¦â
- .Cells.Interior.ColorIndex = .Cells.Font.ColorIndex
- .EnableSelection = xlNoSelection
- .Protect PassWord:=±K½X, DrawingObjects:=True
- End With
- Next
- End Sub
- Private Sub My_UnProtect(Y As Boolean)
- Application.ScreenUpdating = False
- With ActiveSheet
- .Unprotect ±K½X
- If Y = True Then
- .Cells.Font.ColorIndex = ¦rÅéÃC¦â
- .Cells.Interior.ColorIndex = xlNone
- Application.CommandBars.FindControl(ID:=30029).Enabled = True
- Else
- .Cells.Font.ColorIndex = «OÅ@¦â
- .Cells.Interior.ColorIndex = .Cells.Font.ColorIndex
- .EnableSelection = xlNoSelection
- .Protect PassWord:=±K½X, DrawingObjects:=True
- Application.CommandBars.FindControl(ID:=30029).Enabled = False
- End If
- End With
- Application.ScreenUpdating = True
- End Sub
- Private Sub Answer_Pass()
- If Answer <> ±K½X Then
- If InputBox("±K½X??", "¿é¤J±K½X") = ±K½X Then Answer = ±K½X
- End If
- My_UnProtect (IIf(Answer = ±K½X, True, False))
- End Sub
½Æ»s¥N½X |
|