2013-03-15 76 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