首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Office Mac 2011 :如何创建新的Word文档并使用applescript保存?

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

Stack Overflow用户
提问于 2012-12-26 19:39:01
回答 1查看 2.8K关注 0票数 1

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

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

这是我尝试过的:

代码语言:javascript
复制
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

你能帮我个忙吗?

EN

回答 1

Stack Overflow用户

发布于 2012-12-26 21:52:12

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

代码语言:javascript
复制
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

希望这能有所帮助!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14040096

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档