admin管理员组文章数量:1591986
Excel文件夹加密可以使用VBA代码来实现,具体步骤如下:打开Excel文件,按“Alt+F11”打开VBA编辑器;
Excel文件夹加密可以使用VBA代码来实现,具体步骤如下:
1. 打开Excel文件,按“Alt+F11”打开VBA编辑器;
2. 在VBA编辑器中,打开“插入”菜单,选择“模块”;
3. 在模块窗口中,粘贴以下代码:
Public Function EncryptFolder(strFolderPath As String, strPassword As String)
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Dim strParentFolder As String
strParentFolder = fso.GetParentFolderName(strFolderPath)
Dim objShell As Object
Set objShell = CreateObject("Shell.Application")
Dim objFolder As Object
Set objFolder = objShell.Namespace(strParentFolder)
Dim objFolderItem As Object
Set objFolderItem = objFolder.PName(fso.GetFileName(strFolderPath))
objFolderItem.InvokeVerbEx ("Encrypt")
objFolderItem.InvokeVerbEx ("Properties")
Dim objProperty As Object
Set objProperty = objFolderItem.GetDetailsOf(Nothing, 19)
Dim objWshShell As Object
Set objWshShell = CreateObject("WScript.Shell")
objWshShell.SendKeys strPassword & "{TAB}" & strPassword & "{ENTER}"
Set objProperty = Nothing
Set objFolderItem = Nothing
Set objFolder = Nothing
Set objShell = Nothing
Set fso = Nothing
End Function
4. 保存并关闭VBA编辑器;
5. 在Excel文件中,按“Alt+F8”打开宏管理器,选择上面刚刚添加的宏,点击“运行”;
6. 在弹出的对话框中,输入要加密的文件夹路径和密码,点击“确定”即可完成Excel文件夹加密。
版权声明:本文标题:excel文件夹加密怎么设置(含代码示例) 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/xitong/1728128278a1146491.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论