Reputation: 130
Using Applescript, I want to open a Microsoft Word Document in read only mode.
The Word Applescript Dictionary indicates that I should be able to do this, but it doesn't appear to work. Using the following, the document opens in read/write mode:
tell application "Microsoft Word"
open file "Macintosh HD:Users:Shared:test.docx" with read only
end tell
I can open a document in read only mode with the following Visual Basic (VB):
Sub Test()
Documents.Open fileName:="Macintosh HD:Users:Shared:test.docx", ReadOnly:=True
End Sub
I would just use a VB script, but the ability to call VB from Applescript has been removed in Word 2011 ("do Visual Basic" is no longer in the dictionary. You can call a predefined macro, but I don't think you can pass variables to it, so a macro would not work in my situation).
Any suggestions? Thanks
Upvotes: 2
Views: 1638
Reputation: 130
Using "open file name", instead of just "open file" resolved the issue.
tell application "Microsoft Word"
open file name "Macintosh HD:Users:Shared:test.doc" with read only
end tell
Upvotes: 1