1

我正在尝试在 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

请问你能帮帮我吗 ?

4

1 回答 1

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

希望这可以帮助 !

于 2012-12-26T13:52:11.977 回答