更新时间:2022-11-25 10:29:45
这将检查工作簿文件夹的访问列表,以查看用户名是否出现在列表中.如果是这样,则保存文件.
This checks the access list of the workbook's folder to see if the user's name appears in the list. If it does, then save the file.
If Instr(1, Environ("USERNAME"), CreateObject("WScript.Shell").Exec("CMD /C ICACLS """ & _
ThisWorkbook.Path & """").StdOut.ReadAll) > 0 Then ThisWorkbook.Save
通过打开命令提示符,通过它运行ICACLS命令并读取该命令的输出来执行此操作.然后,它使用InStr()方法查看用户名是否出现在该输出中.
It does this by opening a command prompt, running the ICACLS command through it and reading the output from that command. Then it uses the InStr() method to see if the username appears in that output.