Open Excel File as Read Only in Vba
As documents are passed around, upwards or downward, perhaps one needs to think well-nigh restricting what the other users tin can do. Peradventure it'south okay to make a few changes to see how things add up only imagine the chain consequence of accidentally saving an experimental modify to a very important document. Or fifty-fifty accidentally hitting a cardinal somewhere. Such changes have reported thousands of losses to companies.
Scary talk aside and solution-storming in, if you're aiming for a consummate restriction where jail cell values can't be inverse at all, you're looking for sheet protection. Merely if information technology'south okay to make changes to the file every bit long as they'll exist restricted from being saved, you're heading right for Read-Only.
We have prepared this tutorial on how to open Excel in Read-Only mode. You will notice few easy methods to do that including VBA. Nosotros've also covered two options for those who need to take the users of the file reminded that they demand to access the file as Read-Simply.
Simply basically, what happens in Read-Merely Mode? Firstly, the file proper name at the top of the workbook gets a Read-Only tag:
When you lot make any changes to the file, they will apply but when you attempt to save the file, you'll have to salve information technology as a re-create because the original file tin't exist overwritten in Read-Only mode.
Now we tin jump on the "how" part of opening a file as Read-But. Let's begin.
Open Workbook every bit Read-Merely Using File Open Dialog
Instead of regularly opening a file, it tin exist opened as Read-But, and below are the steps:
- Open Excel and navigate to the File tab, on the ribbon.
- Click on the Open button from the left panel and select Scan from the options to access the Open up
- Browse and select the file y'all want to open as Read-Simply.
- Click on the arrow of the Open command push button at the bottom-correct of the dialog box and select Open Read-Only from the listing.
Selecting this option will open the file every bit Read-Only.
Open up Workbook as Read-Only Using VBA
Any workbook can be opened as Read-Only using VBA. Y'all need to run the file path in the provided code and feed it in VBA via a module and the chosen file will open up every bit Read-But. We have the steps for this below:
- Open a new Excel file.
- Open the VB editor from the Developer tab or press Alt + F11.
- In the editor, click on Insert and select Module to open the Module
- Copy-paste the following code in the Module window simply alter the file path to the file path including the filename of the workbook you desire to open as Read-Only.
Sub Open_Workbook_As_Read_Only()
'Open a Workbook as Read-Only
Workbooks.Open "C:\Employee data.xlsx", ReadOnly:= True
End Sub
- Printing the F5 key to run the command.
The called file will open every bit Read-Only. You tin can close the previous file.
Forcing the File to Always Open with a Read-Simply Prompt
Someone may forget to open a file every bit Read-Just, oops. Instead of opening the file every time as Read-Only, the file tin can exist fabricated to pop up a prompt, suggesting the user to open up the file in Read-Only manner whenever the file is accessed. There are a couple of ways of setting the file with a Read-Only prompt that we have detailed as follows.
Forcing the File to Open with a Read-Only Prompt Using Save Equally Options
This method utilizes the tools in the Save As dialog, setting it with a Read-Simply recommend. These are the steps:
- With the file open, become to the File tab and select Relieve Equally from the left pane. Select the location for saving the file. The Save As dialog box volition open.
- Click on the Tools push at the bottom of the dialog box and select General Options.
- In the General Options dialog box, check the Read-only recommended checkbox, then click OK.
- Click the Save command push button in the Save As dialog box.
- Shut the file. When opening the file, the Read-Only recommend will pop up:
The user tin even so cull to access the editable file by selecting No hither but the prompt does its piece of work to serve as a reminder.
Forcing the File to Open with a Read-Merely Prompt from Protect Workbook Options
Another manner to fit the file with a Read-Simply prompt is to utilize the Protect Workbook options from the Info settings. Hither'southward how to go most it:
- Click on the File tab of the opened workbook.
- In the File card, select Info from the left console and then click on the Protect Workbook push button to access the options.
- Select Always Open Read-Simply from the options.
- After selecting the choice, the workbook will have been protected with the Read-Simply prompt.
- Close the file and relieve the changes.
And that'southward washed. Now the file will show the prompt whenever accessed.
At present if you're done with only reading, have a go at applying 1 of the methods to open a file equally Read-Simply. Next fourth dimension you consider saving your file from meddling, see if you want to have it run equally Read-Only or have the workbook protected; Excel hardly comes with a single possibility for things. Run across yous shortly with more possibilities from E'er-Ever-Excel-land!
atteberyliblaingledy.blogspot.com
Source: https://www.exceltrick.com/how_to/open-excel-read-only-mode/
0 Response to "Open Excel File as Read Only in Vba"
Post a Comment