How to Open a Word Document as Read-Only with VBA
Question details
The user needs a way to open a Word document in read-only mode using VBA automation, specifically inquiring about the Application.FollowHyperlink method.

- Product
- Microsoft Word
- Device & OS
- not provided
- Scenario
- Automating document handling where a file must be viewed safely without allowing accidental modifications to the original file.
- Observed behavior
- The user is looking for the correct VBA syntax to force a Word document to open in read-only mode, as default hyperlink methods do not provide a native parameter for this.
Ensure you have the Developer tab enabled in your Word processor and have basic familiarity with writing and executing scripts in the VBA editor.
Use the Documents.Open Method in Word Automation
The most reliable way to open a document as read-only is to use Word automation and pass 'True' to the ReadOnly argument of the Documents.Open method.
While the Application.FollowHyperlink method is great for opening web links, it lacks a dedicated read-only parameter for local files. Using the Word.Application object gives you full control over how the document is initialized and protected.
Press ALT + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor.
Write the code to create the Word application object by typing: Set oWord = CreateObject("Word.Application")
Use the Documents.Open method with the ReadOnly argument explicitly set to True: Set oWordDoc = oWord.Documents.Open("C:\Path\YourDocument.docx", , True)
Ensure the Word window appears to the user by adding the line: oWord.Visible = True

Set the File Attribute to Read-Only using SetAttr
If you must use Application.FollowHyperlink or another opening method, you can temporarily change the file's system attribute to read-only before opening it.
Open and Protect Word Documents Easily in WPS Office
WPS Office provides powerful document protection tools. Whether you need to run VBA scripts (supported in professional editions) or simply open documents in read-only mode manually to prevent accidental edits, WPS Writer offers a highly compatible and user-friendly solution.
- 1. Launch WPS Office: Open WPS Office on your computer and select WPS Writer from the home screen.
- 2. Access the Open Menu: Click on 'Menu' in the top-left corner and select 'Open' to browse your computer for the document.
- 3. Select Read-Only Mode: In the file explorer dialog box, click the drop-down arrow next to the 'Open' button and select 'Open in Read-Only Mode'.

Frequently Asked Questions
Why doesn't Application.FollowHyperlink open my document as read-only?
The Application.FollowHyperlink method is designed to navigate to URLs or open files in their default system state. It does not have a built-in parameter to force a local document to open in read-only mode, which is why Documents.Open is the recommended alternative.
Can I remove the read-only attribute using VBA after viewing?
Yes, you can use the SetAttr function in VBA to change the file attribute back to normal by executing SetAttr "C:\Path\YourDocument.docx", vbNormal.
Does WPS Office support VBA macros for opening documents?
Yes, WPS Office provides macro support in its Professional and Business editions. These editions are highly compatible with standard VBA scripts, allowing you to use similar automation methods to open documents.
What happens if I try to save a read-only document?
If a document is opened in read-only mode, any attempt to save it will trigger the 'Save As' dialog box. This forces you to save the file with a new name or in a new location, protecting the original file from being overwritten.




