28

When I double-click on a CSV file on a network share, the file is opened in Microsoft Excel (which is what I want). However, Excel assumes that I'm going to modify the file, and that everyone else is too, and so puts a lock on it.

In practice I very rarely actually want to modify these files, merely read from them. And if I have the file open in an Excel window in the background, it stops anyone else from opening the same file.

I am aware that I can manually open a file as read-only from the File -> Open dialog within Excel. However I almost always open files by double-clicking on them in Explorer (or Outlook, for attachments). Is it possible to change the file association so that the default handler for CSV files is "Excel in read-only mode"? Is there a command-line argument that I can use in the Open With... dialog to achieve this?

Or more bluntly - when I am looking at a CSV file in Windows Explorer, is there an easier way to open it read-only than starting up Excel myself, selecting File -> Open, choosing "read only" from the dropdown, manually navigating to the same folder in the hierarchy, and then opening the file?

(I am happy to have to jump through hoops on the rare occasions that I want to modify and save a file.)

4 Answers 4

17

I was able to reach a satisfactory conclusion to this by adding the following keys to my registry:

[HKEY_CLASSES_ROOT\Excel.CSV\shell\Open_in_read_only_Excel]
@="Open read-only in Excel"

[HKEY_CLASSES_ROOT\Excel.CSV\shell\Open_in_read_only_Excel\command]
@="\"C:\\Program Files (x86)\\Microsoft Office\\Office12\\EXCEL.EXE\" /r \"%1\""

These create an entry on the right-click shell menu in Windows Explorer called "Open read-only in Excel". When selected, this launches Excel with the /r flag (as per the command in the second key), which opens the file in read-only mode.

This is not perfect - I would rather that this were the default action for a CSV file, and that a context option was needed to launch in read-write mode. However it is a vast improvement on the situation before.

2
  • 7
    you are almost there - to now set that action as default, set the key [HKEY_CLASSES_ROOT\Excel.CSV\shell, value (Default) to Open_in_read_only_Excel
    – SeanC
    Oct 23, 2012 at 14:39
  • Today it's "C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE" /r "%1" Jan 31 at 23:13
5

Here's the equivalent of Andrzej Doyle's answer for Excel 2013, which uses DDE, and also sets "Open (read-only)" as the default action:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Excel.CSV\shell]
@="OpenReadOnly"

[HKEY_CLASSES_ROOT\Excel.CSV\shell\OpenReadOnly]
@="Open (read-only)"

[HKEY_CLASSES_ROOT\Excel.CSV\shell\OpenReadOnly\command]
@="\"C:\\Program Files\\Microsoft Office 15\\Root\\Office15\\EXCEL.EXE\" /dde"

[HKEY_CLASSES_ROOT\Excel.CSV\shell\OpenReadOnly\ddeexec]
@="[open(\"%1\" /ou \"%u\",,1)]"

[HKEY_CLASSES_ROOT\Excel.CSV\shell\OpenReadOnly\ddeexec\topic]
@="system"

(Yes, it's the ,,1 that makes the file read-only. How obscure!)

3
  • Just to clarify: The accepted method doesn't work anymore for Excel 2013? What exactly is DDE? (haven't googled it yet)
    – nixda
    Oct 16, 2015 at 13:24
  • It still works if you update the Excel EXE path, but the default "Open" command for Excel 2013 uses DDE, so I thought I'd better stick with that to be safe.
    – EM0
    Oct 16, 2015 at 14:00
  • @nixda DDE is an old way of doing inter-process communication that is still well supported by several parts of MS Office. Jan 12, 2016 at 11:10
4

There is a lightweight program from Microsoft themselves called Microsoft Excel Viewer. (just google) This does not lock files when viewing them. It can be installed even if full size Microsoft Excel is present.

Unfortunately I have not yet found how to set windows to use the 'Viewer' as its default Excel application (unless I uninstall full size Excel). If I could do that we would all have a very neat solution. So does anyone know how to do that?

4
  • 1
    I also couldn't do that. Neither could pin the tool to Taskbar. But it is a good solution anyway.
    – Alisa
    Mar 31, 2017 at 18:45
  • 2
    For posterity, they're pulling support for the Excel Viewer Apr 2018 -- it should still work past then, but you won't be able to download it or get updates after that.
    – drzaus
    Dec 12, 2017 at 16:44
  • Excel viewer was retired inApril 2018 ( docs.microsoft.com/en-us/office/troubleshoot/excel/… ).
    – Brian
    Oct 23, 2019 at 17:06
  • Alas this was retired in 2018 :-( Dec 14, 2022 at 1:08
3

If you have control over how the file is saved then you can have it saved with an option that prompts read-only access whenever it is opened.

File > SaveAs > Tools > General Options... > Read-only recommended

1
  • 6
    That doesn't appear to work with CSV files (which makes sense as they have nowhere to store metadata). Plus the files are created by an automated FTP fetch, so unless a Unix process could set this flag I don't think this approach will bear fruit. Oct 22, 2012 at 10:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .