通过VBA返回PowerShell的结果
我在.xlam模块中创build了示例VBA函数,我想返回简单的Powershell Get-Datestring:
Private Function test1() As String test1 = Shell("Powershell Get-Date") End Function
在Excel的单元格中,当我尝试运行= test1()时,有4位数字:
1456 1296 4228 1232 4976 5328 4844 4560 2572
我怎样才能做到这一点?
如文档所述 , Shell()
不返回外部命令的输出,而是返回其任务ID。 如果要读取命令输出,请参阅此类似问题的答案 。
如果您只想获取具有当前时间戳的string,则无需为PowerShell提供这些信息。 像这样的东西应该工作得很好:
Private Function test1() As String test1 = CStr(Now) End Function