Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Is there a way to save an Excel file as Read-Only?

Posted on 2010-08-19
15
352 Views
Last Modified: 2012-05-10
Is there a way to save an Excel file as Read-Only via VBA?

NOT, "Read-Only Recommended," but rather actually "Read-Only" in the file properties.
0
Comment
Question by:HaimD
  • 4
  • 4
  • 3
  • +3
15 Comments
 
LVL 14

Expert Comment

by:athomsfere
ID: 33476133
Right click the file, modify all user securities to "read only"

They will be able to save a copy, but that file is read only.
0
 

Author Comment

by:HaimD
ID: 33476152
Need it via VBA
0
 
LVL 23

Expert Comment

by:Kamaraj Subramanian
ID: 33476186

To make a Excel file read only (Microsoft Excel 2003),

    * Goto Tools ->Options->Security (The Tools menu in the worksheet menu bar)
    * Check the READ-ONLY RECOMMENDED box.

This would make your file read only and when the file is opened, it would prompt you with the message box whether you want the file to be opened in read only mode or not. If you click YES, the file would open in read only mode. If you click NO, the file would open in read write mode and you can save your changes.

For Microsoft Excel 2000 and other previous versions

    * Goto File->Save As
    * Click the TOOLS button on the right corner and select GENERAL OPTIONS
    * Now check the READ-ONLY RECOMMENDED box.

This works well in Microsoft Excel 2003 also.

The above option, though making the file read only, gives the user the option to edit it. So even if an user unknowingly presses the NO button , when prompted for read only opening, he may still be able to edit the file. If you want to prevent this then,

    * Navigate to your file through Windows Explorer or the File Open Box and select it.
    * RIGHT CLICK and select PROPERTIES
    * Check the READ ONLY box.

This always open the file read only and even if you already made your file read only, by using the first option, this overrides it since this function is part of the operating system rather than the application. To make the file read write again, just uncheck the READ ONLY box.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 5

Expert Comment

by:INHOUSERES
ID: 33476223
ActiveWorkbook.SaveAs Filename:=FN, ReadOnlyRecommended:=True
0
 

Author Comment

by:HaimD
ID: 33476233
Need Read-Only via VBA.  Not read-only recommended via checkbox.
Thanks
0
 

Author Comment

by:HaimD
ID: 33476240
That's ReadOnlyRecommended...need Read-Only
0
 
LVL 17

Accepted Solution

by:
calacuccia earned 500 total points
ID: 33476259
Something likethis

SetAttr pathname, attributes

To set ReadOnly=True
SetAttr "C:\Blank.xls", vbReadOnly

To set ReadOnly=False
SetAttr "C:\Blank.xls", vbNormal
0
 
LVL 5

Expert Comment

by:INHOUSERES
ID: 33476289
SetAttr "C:\Blank.xls", vbReadOnly
0
 
LVL 13

Expert Comment

by:MWGainesJR
ID: 33476465
If you guys are going to copy from another site, I would reccomend giving that site the credit.......
0
 
LVL 5

Expert Comment

by:INHOUSERES
ID: 33476507
Then why post the question if the answer is easily found?
0
 
LVL 13

Expert Comment

by:MWGainesJR
ID: 33476528
going along with that these guys provided, you could also use
setattr thisworkbook.fullname, vbreadonly
thisworkbook.close true
0
 
LVL 13

Expert Comment

by:MWGainesJR
ID: 33476554
If this person pays to use this site, I would also come here first.....
Just saying, it's always recommended to give credit where the solution is found.....or either link to it......
0
 
LVL 5

Expert Comment

by:INHOUSERES
ID: 33476604
When I answer questions, I assume that the poster has already done a quicky google search.
0
 
LVL 17

Assisted Solution

by:calacuccia
calacuccia earned 500 total points
ID: 33476648
Which is true, thereby the source: http://www.mrexcel.com/forum/showthread.php?t=80796
0
 

Author Closing Comment

by:HaimD
ID: 33486790
Exactly what I needed.
Thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question