禁止excel另存为代码
答案:2 悬赏:80 手机版
解决时间 2021-03-02 02:39
- 提问者网友:美人性情
- 2021-03-01 03:29
做了个模板,防止另存为的代码是?
最佳答案
- 五星知识达人网友:拾荒鲤
- 2021-03-01 03:54
Private Sub workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim response As Long
If SaveAsUI = True Then
response = MsgBox("该工作簿不允许用“另存为”来保存," & "你要用原工作簿名称来保存吗? ", vbQuestion + vbOKCancel)
Cancel = (response = vbCancel)
If Cancel = False Then Me.Save
Cancel = True
End If
End Sub
Dim response As Long
If SaveAsUI = True Then
response = MsgBox("该工作簿不允许用“另存为”来保存," & "你要用原工作簿名称来保存吗? ", vbQuestion + vbOKCancel)
Cancel = (response = vbCancel)
If Cancel = False Then Me.Save
Cancel = True
End If
End Sub
全部回答
- 1楼网友:青尢
- 2021-03-01 04:34
解决方案是:
在工具-保护-保护工作表-设置密码,把下面的勾选全取消,
工作表就不能修改,就是保存或另存为了也不能修改。
也可以用vb宏代码禁止:
在宏编辑器里的thisworkbook下写入代码:
private sub workbook_beforeclose(cancel as boolean)
me.saved = true
end sub
private sub workbook_beforesave(byval saveasui as boolean, cancel as boolean)
cancel = true
end sub
文件打开什么样子,关闭时将不会有任何变化。
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯