你可以使用以下代码示例来获取Word文档的文件路径,但如果结果为空,则可能是因为Word文档没有保存到磁盘上。
tell application "Microsoft Word"
set docPath to path of active document
if docPath is missing value or docPath is equal to "" then
display dialog "Document path is empty."
else
display dialog "Document path: " & docPath
end if
end tell
请确保在运行脚本之前已经打开了Word文档。如果文档未保存到磁盘上,路径将为空。