4
votes

I've been struggling to find a way to open a Read-only document in Normal/Edit mode instead of Reading mode with MS Word 2013. Word 2013 by default enables the start up option to "Open e-mail attachments and other uneditable files in reading view".

How would I go about disabling this option or changing the view from Reading to Normal/Edit view when the document is opened. (I need to keep the document as read-only as it might be accessed by multiple people at once)

Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Open(documentPath,,True)
objWord.ActiveWindow.ActivePane.View.Type = wdNormalView

I have tried to set the view mode using the above but received the an error code shown below. I looked at other variations of line 3 but can't get it to work. I'm still working my way around learning VBScript so I'm assuming i'm not doing this the right way.

Error: One of the values passed to this method or property is out of range
Code: 800A16D3
Source: Microsoft Word

Thanks.

1

1 Answers

6
votes

You're using VBScript - it doesn't understand what wdNormalView means. This is an internal value for VBA. You need to find the actual value held for this constant and apply that instead. The constant is a WdViewType and the values are as follows:

Name          Value    Description
wdMasterView    5      A master view.
wdNormalView    1      A normal view.
wdOutlineView   2      An outline view.
wdPrintPreview  4      A print preview view.
wdPrintView     3      A print view.
wdReadingView   7      A reading view.
wdWebView       6      A Web view.

So the option you want to select is 1. Try the following code and see if this works:

Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Open(documentPath,,True)
objWord.ActiveWindow.ActivePane.View.Type = 1