阻止用户在特定路径保存文件 [英] Prevent user to save file at specific path
问题描述
大家好,
我想阻止用户保存+另存为excel文件到特定文件夹。下面是阻止用户使用save的代码,但是当用户使用save as时它不起作用。
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean,Cancel As Boolean)
如果ThisWorkbook.Path =" T:\Public\Template"然后
如果不是SaveAsUI那么
MsgBox"你不能在这条路径上保存这个模板选择其他路径。",vbInformation
取消= True
结束如果
结束如果
结束次级
我希望该用户无法将此文件保存在 T:\Public\Template
谢谢,
Zav
嗨zaveri,
基于我的 测试,它适合我。所以我认为您应该检查路径(WorkBookPath)是否正确并确认是否已输入条件。您可以打印出来进行检查。
另外,请更新代码"Not SaveAsUI"。 to"SaveAsUI"。
最好的问候,
Simon
Hi All,
I want to prevent user to save + save as the excel file to particular folder. Below is the code which prevents user using save but it do not work when user uses save as.
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) If ThisWorkbook.Path = "T:\Public\Template" Then If Not SaveAsUI Then MsgBox "You cannot save this template at this path Choose other path.", vbInformation Cancel = True End If End If End Sub
I want that user cannot save this file on T:\Public\Template
Thanks,
Zav
Hi zaveri,
Based on my test, it works for me. So I think that you should check if the path(WorkBookPath) is correct and confirm that the condition has been entered. You can print it out to check it.
Also, please update the code "Not SaveAsUI" to "SaveAsUI".
Best Regards,
Simon
这篇关于阻止用户在特定路径保存文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!