2

When I press Shift+Right-click when clicking on a workbook's filename, I get the "Open as Read-Only" option in the context menu, but when I click this option and the workbook opens, it's in read/write mode, and I'm able to save changes.

How can I actually open the workbook in Read-Only?

sigil
  • 505

4 Answers4

3

If you wish to open an Excel File as "Read Only", try this..

Open Excel. Then press CTRL + O, to open the Open File dialog box.

Then try this to open the file as read only:

enter image description here

Firee
  • 1,910
0

I had the same problem. (Apparently Microsoft still didn’t fix this bug.)

In the registry, I found that the command for "Open as Read-Only" is "C:\Program Files (x86)\Microsoft Office\Root\Office16\EXCEL.EXE"/h"%1".

But, according to the documentation, it should be /r.
https://support.microsoft.com/en-us/office/command-line-switches-for-microsoft-office-products-079164cd-4ef5-4178-b235-441737deb3a6#Category=Excel

I changed it in the registry, now it works.

Solution

⚠️ WARNING
Editing the registry incorrectly can damage your system and can result in data loss or the need to reinstall your system!

Note
You have to change the installation path, according to you installation.
I Use Excel 2019, which apparently is version 16.
If you change it in the registry, use the path that is already there and just change /h to /r.

Go to [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Excel.Sheet.12\shell\OpenAsReadOnly\command]
and change (Default)
from "C:\Program Files (x86)\Microsoft Office\Root\Office16\EXCEL.EXE" /h "%1"
to "C:\Program Files (x86)\Microsoft Office\Root\Office16\EXCEL.EXE" /r "%1".

Alternative

Create a .reg file with following content:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Excel.Sheet.12\shell\OpenAsReadOnly\command] @=""C:\Program Files (x86)\Microsoft Office\Root\Office16\EXCEL.EXE" /r "%1""

Remember to change the installation path accordingly to your installation.

Now you can install that reg file.

Martini Bianco
  • 139
  • 1
  • 3
0

If you want to say a user that you can just run this, so ....

I think your answer at last is using two batch files :

Read-only batch file codes:

@echo off
attrib <file.xlsx> +a +r
file.xlsx

Normal batch file codes :

@echo off
attrib <file.xlsx> -a -r
file.xlsx

I know that; this can be just the last way ...

shA.t
  • 500
-1

In case you want to open a word (in read only) because another one will use this later so you can do as following:

Open word, then exploring to the word you want to open read-only, choose option read-only option in below, so you can read-only the file.