Excel 工作簿桌面快捷方式带有自动密码吗?

Excel 工作簿桌面快捷方式带有自动密码吗?

我的安全 LAN(无 WAN)计算机上有一堆受密码保护的 Excel 工作簿。

是否可以将密码解析为快捷方式,以便只要密码正确就会自动打开工作簿?

例如:

"S:\resources\Audit.xls" -password "mypass"

答案1

没有直接的方法,但只需一点编码,您就可以让 Excel 处理命令行参数并从启动器电子表格中打开它。

使用如下的快捷方式:

"C:\Program Files\Microsoft Office\Office12\EXCEL.EXE" /e/myfilename/mypassword "C:\MyExcelFiles\test.xlsb"

您可以使用以下代码来获取命令行 - 然后您必须提取使用 /e 传递的参数,因为整行都会返回

Declare Function StrLenA Lib "kernel32.dll" Alias "lstrlenA" (ByVal Ptr As Long) As Long
Declare Function GetCommandLineA Lib "kernel32.dll" () As Long
Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (ByRef pDst As Any, pSrc As Any, ByVal ByteLen As Long)

Function GetCommandLine() As String

Dim CmdStr As Long
Dim N As Long
Dim Buffer As String

   CmdStr = GetCommandLineA 'Get a pointer to a string, which contains the command line
   N = StrLenA(CmdStr) 'Get the length of that string
   Buffer = String(N, Chr$(0)) 'Create a buffer
   CopyMemory ByVal Buffer, ByVal CmdStr, N 'Copy to the buffer
   GetCommandLine = Buffer

End Function

相关内容