Others

How to Open a Word Document as Read-Only with VBA

John WilsonJohn Wilson Oct 29, 2026 871 views

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.

How to Open a Word Document as Read-Only with VBA
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.
Before you start

Ensure you have the Developer tab enabled in your Word processor and have basic familiarity with writing and executing scripts in the VBA editor.

Solution 1Recommended

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.

1
Open the VBA Editor

Press ALT + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor.

2
Initialize the Word Application

Write the code to create the Word application object by typing: Set oWord = CreateObject("Word.Application")

3
Open with Read-Only Parameter

Use the Documents.Open method with the ReadOnly argument explicitly set to True: Set oWordDoc = oWord.Documents.Open("C:\Path\YourDocument.docx", , True)

4
Make the Application Visible

Ensure the Word window appears to the user by adding the line: oWord.Visible = True

Use the Documents.Open Method in Word Automation
Automation Control: This method ensures the document is strictly locked from saving over the original file during that specific automation session.
Seamless Document Management

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. 1. Launch WPS Office: Open WPS Office on your computer and select WPS Writer from the home screen.
  2. 2. Access the Open Menu: Click on 'Menu' in the top-left corner and select 'Open' to browse your computer for the document.
  3. 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'.
Highly compatible with Microsoft Word formats (.doc, .docx)Built-in document protection and read-only viewing modesLightweight application with a familiar user interfaceSupports advanced macros and VBA in professional versions
microsoft office alternative - wps office

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.