Ms word 尝试使用用户输入自动保存新word文档

Ms word 尝试使用用户输入自动保存新word文档,ms-word,applescript,Ms Word,Applescript,我正在使用Applescript,但我很难让它正常工作,可能是因为我对变量的理解非常有限。无论如何,这是我到目前为止的剧本: tell application "Microsoft Word" activate end tell display dialog "Input Document Name" default answer "" set answer to text returned of result tell application "Microsoft Word" c

我正在使用Applescript,但我很难让它正常工作,可能是因为我对变量的理解非常有限。无论如何,这是我到目前为止的剧本:

tell application "Microsoft Word"
activate

end tell

display dialog "Input Document Name" default answer ""
set answer to text returned of result

tell application "Microsoft Word"
    create new document
    save document as answer

end tell

我将非常感谢任何帮助,甚至是重定向到相关职位。谢谢。

您必须仔细阅读相关的Applescript词典,并找出Applescript所期望的内容。在这种情况下,需要另存为。如果在单词applescript字典中查找“另存为”,首先看到的是

save as document
[file name text]
让我们试着把你的东西插进去。而不是将文档另存为您至少需要的答案

save as document file name answer
但这还不够,因为文档本身并不是任何东西的名称,也不是对任何文档的引用。此时,您需要查看创建新文档的功能

create new document
(various parameters)
-> document
所以你可能需要的是

set theDocument to create new document
save as theDocument file name answer
这并不总是那么简单,也不是所有的东西都能从字典中看出来。例如,我不认为字典告诉您word创建新文档时,它通常会成为活动文档。如果你知道在所有可能的情况下,这个词就是这么做的,你也可以使用

create new document
save as active document file name answer

但第一种方法更可靠。

什么不起作用?你想要它做什么?我想要它保存为输入文本。我得到结果错误:错误Microsoft Word得到错误:文档无法理解保存消息。文件编号-1708