Office Mac 2011:如何创建新的Word文档并使用applescript保存?

时间:2012-12-26 11:39:01

标签: ms-word applescript

我试图在Office 2011上为Word编写简单的AppleScript而没有成功。 我找到了这个链接,但Office 2011的语法不同,谷歌不是我这个任务的朋友...... http://www.mactech.com/articles/mactech/Vol.23/23.01/2301applescript/index.html

我想要的:创建一个新文档,编写日期并将新文档保存在我的主文件夹中

以下是我的尝试:

tell application "Microsoft Word"
activate
make new document
set theDate to current date
set text of active document to theDate as text
save as active document file name "/Users/user/toto.doc"
end tell

你能帮我吗?

1 个答案:

答案 0 :(得分:0)

这适用于我的Mountain Lion + MS Word 2011:

set outputPath to (path to home folder as string) & "toto.doc"

tell application "Microsoft Word"
    activate
    make new document
    set theDate to ((current date) as string)
    tell active document
        set theRange to create range start 0 end 0
        set content of theRange to theDate
    end tell
    set activeDoc to active document
    save as activeDoc file name outputPath
end tell

希望这有帮助!