Select the product you need help with
- Internet Explorer
- Windows Phone
- More products
Word document opens as read-only when you try to programmatically open the document
Article ID: 275976 - View products that this article applies to.
This article was previously published under Q275976
When you try to programmatically open a Microsoft Word document, the document opens as a read-only document and you cannot edit the document.
When you add the code
the document still opens as a read-only document.
When you open the same document using the Open command, the following message appears:
You can open the document for editing by clicking Yes on the message.
PathName should be opened as read-only unless changes to it need to be saved. Open as read-only?
This problem occurs because Visual Basic opens any document with the ReadOnlyRecommended attribute set to true as a read-only document, even if you attempt to set the ReadOnly attribute to false.
Note The following example applies to Word 2003 and 2002:
To work around this problem, use the following Word Basic macro instead of the Visual Basic macro shown in step 8 of the "Cause" section of this article:
With this macro the file can be edited after it opens.
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.