2

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

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 脚本,但从 Applescript 调用 VB 的功能已在 Word 2011 中删除(“do Visual Basic”不再在字典中。您可以调用预定义的宏,但我认为您不能将变量传递给它,因此宏在我的情况下不起作用)。

有什么建议么?谢谢

4

1 回答 1

1

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

tell application "Microsoft Word"
    open file name "Macintosh HD:Users:Shared:test.doc" with read only
end tell
于 2013-03-15T08:04:32.963 回答