Private Sub Workbook_Open()
With Application
'禁止拖曳復(fù)制
Application.CellDragAndDrop = False
'禁止自動(dòng)填充
.CellDragAndDrop = False
'屏蔽常用工具欄剪切、復(fù)制、粘貼
.CommandBars(3).Controls("剪切(&T)").Enabled = False
.CommandBars(3).Controls("復(fù)制(&C)").Enabled = False
.CommandBars(3).Controls("粘貼(&P)").Enabled = False
'屏蔽單元格右鍵菜單中的剪切、復(fù)制、粘貼命令
.CommandBars("Cell").Controls("剪切(&T)").Enabled = False
.CommandBars("Cell").Controls("復(fù)制(&C)").Enabled = False
.CommandBars("Cell").Controls("粘貼(&P)").Enabled = False
'屏蔽列右鍵菜單中的剪切、復(fù)制、粘貼命令
.CommandBars("Column").Controls("剪切(&T)").Enabled = False
.CommandBars("Column").Controls("復(fù)制(&C)").Enabled = False
.CommandBars("Column").Controls("粘貼(&P)").Enabled = False
'屏蔽行右鍵菜單中的剪切、復(fù)制、粘貼命令
.CommandBars("Row").Controls("剪切(&T)").Enabled = False
.CommandBars("Row").Controls("復(fù)制(&C)").Enabled = False
.CommandBars("Row").Controls("粘貼(&P)").Enabled = False
'屏蔽編輯菜單中的剪切、復(fù)制、粘貼命令
.CommandBars(1).Controls("編輯(&E)").Controls("剪切(&T)").Enabled = False
.CommandBars(1).Controls("編輯(&E)").Controls("復(fù)制(&C)").Enabled = False
.CommandBars(1).Controls("編輯(&E)").Controls("粘貼(&P)").Enabled = False
'屏蔽鍵盤剪切、復(fù)制、粘貼鍵
.OnKey "^x", ""
.OnKey "^c", ""
.OnKey "^v", ""
End With
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
With Application
'恢復(fù)拖曳復(fù)制
Application.CellDragAndDrop = True
'恢復(fù)自動(dòng)填充
.CellDragAndDrop = True
'恢復(fù)常用工具欄剪切、復(fù)制、粘貼
.CommandBars(3).Controls("剪切(&T)").Enabled = True
.CommandBars(3).Controls("復(fù)制(&C)").Enabled = True
.CommandBars(3).Controls("粘貼(&P)").Enabled = True
'恢復(fù)單元格右鍵菜單中的剪切、復(fù)制、粘貼命令
.CommandBars("Cell").Controls("剪切(&T)").Enabled = True
.CommandBars("Cell").Controls("復(fù)制(&C)").Enabled = True
.CommandBars("Cell").Controls("粘貼(&P)").Enabled = True
'恢復(fù)列右鍵菜單中的剪切、復(fù)制、粘貼命令
.CommandBars("Column").Controls("剪切(&T)").Enabled = True
.CommandBars("Column").Controls("復(fù)制(&C)").Enabled = True
.CommandBars("Column").Controls("粘貼(&P)").Enabled = True
'恢復(fù)行右鍵菜單中的剪切、復(fù)制、粘貼命令
.CommandBars("Row").Controls("剪切(&T)").Enabled = True
.CommandBars("Row").Controls("復(fù)制(&C)").Enabled = True
.CommandBars("Row").Controls("粘貼(&P)").Enabled = True
'恢復(fù)編輯菜單中的剪切、復(fù)制、粘貼命令
.CommandBars(1).Controls("編輯(&E)").Controls("剪切(&T)").Enabled = True
.CommandBars(1).Controls("編輯(&E)").Controls("復(fù)制(&C)").Enabled = True
.CommandBars(1).Controls("編輯(&E)").Controls("粘貼(&P)").Enabled = True
'恢復(fù)鍵盤剪切、復(fù)制、粘貼鍵
.OnKey "^x"
.OnKey "^c"
.OnKey "^v"
End With
End Sub
另:
Sub auto_open() '打開文件執(zhí)行的宏
If Environ("COMPUTERNAME") <> "Administrator" Then '驗(yàn)證計(jì)算機(jī)用戶不是指定名稱時(shí)執(zhí)行
Call 強(qiáng)行關(guān)閉文件 '調(diào)用宏
End If
End Sub
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)
點(diǎn)擊舉報(bào)。