Applescript:从word文档中获取没有文件名的文件路径,但结果为空

Applescript: Get the file path without the file name, from a word document, but the result is empty

我正在尝试从 Word 的前端文档和 Applescript 中获取不带文件名的文件路径,但我得到的是一个空字符串。

这是来自 MacScripter 的代码。

Tell application "Microsoft Word"
  activate
  tell front document
    --full path and file name
    set TheName to get full name as string
    display dialog TheName
    --File path
    set ThePath to get file path as string
    display dialog ThePath
  end tell
end tell

TheName 完美。路径和文件名,但 ThePath 为空。有什么想法吗?

MS Word 仅提供完整路径。使用System Events获取父文件夹

tell application "Microsoft Word"
    set filePath to path of front document
end tell
tell application "System Events" to set parentFolder to path of (container of disk item filePath)