2013-03-15 74 views
2

使用Applescript,我想以只读模式打开Microsoft Word文档。AppleScript - 打开Microsoft Word 2011文档为只读

Word Applescript Dictionary表示我应该可以做到这一点,但它似乎不起作用。使用以下,在文件中读取/写入模式打开:

tell application "Microsoft Word" 
    open file "Macintosh HD:Users:Shared:test.docx" with read only 
end tell 

我可以以只读模式打开一个文档与下面的Visual Basic(VB):

Sub Test() 
    Documents.Open fileName:="Macintosh HD:Users:Shared:test.docx", ReadOnly:=True 
End Sub 

我只想用一个VB脚本,但是在Word 2011中已经删除了从Applescript调用VB的能力(“Visual Basic”已不在字典中,您可以调用预定义的宏,但我认为您不能将变量传递给它,所以一个宏不适用于我的情况)。

有什么建议吗?谢谢

回答

1

使用“打开文件名”,而不是“打开文件”解决了问题。

tell application "Microsoft Word" 
    open file name "Macintosh HD:Users:Shared:test.doc" with read only 
end tell 
+0

今天完全保存了我的培根。谢谢! – Jonathan 2014-02-14 00:59:18