MAC上的变量用户名是什么

时间:2017-09-23 19:57:58

标签: vba macos applescript

我录制了一个宏来将工作簿保存到Mac上的桌面,但我无法弄清楚如何使用户名变量名称类似于VBA environ $(用户名)

ActiveWorkbook.SaveAs Filename:="/Users/username/Desktop/test.xls", _

FileFormat:= xlExcel8,密码:=“”,WriteResPassword:=“”,_ ReadOnlyRecommended:= False,CreateBackup:= False

1 个答案:

答案 0 :(得分:0)

在AppleScript中,您可以设置变量,例如theFilename用户桌面的路径和文件名,例如:

set theFilename to POSIX path of (path to desktop as string) & "filename.xls"

请查看path to (folder)的AppleScript文档,了解此表单适用的所有不同位置。

如果它只是您想要的用户名:

set theShortUserName to short user name of (get system info)

或者

set theShortUserName to do shell script "printf $USER"