ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Read Only Enforcement (https://www.excelbanter.com/excel-programming/291152-read-only-enforcement.html)

andycharger[_10_]

Read Only Enforcement
 
Is there a way in a macro to force read only?

I see that you can set readonlyRecommended=True.

However, when my users open up the file, they still have the ability t
open it as normal if they select it with the warning.

What I want to do if force my file to save in readonly and not let the
open it any other way.

Is there a way to do this when saving the file in the macro before
give it to my staff

--
Message posted from http://www.ExcelForum.com


No Name

Read Only Enforcement
 
Try setting the file attribute to read-only, this way
Excel will open as read-only without asking.
This is an operating system level attribute so potentially
could be changed outside of Excel.

In VBA use......
SetAttr "file", vbReadOnly

Since you presumably do not want your staff to change the
contents you might want to prevent "saving" this file as
well by disabling the save menu options.

-----Original Message-----
Is there a way in a macro to force read only?

I see that you can set readonlyRecommended=True.

However, when my users open up the file, they still have

the ability to
open it as normal if they select it with the warning.

What I want to do if force my file to save in readonly

and not let them
open it any other way.

Is there a way to do this when saving the file in the

macro before I
give it to my staff?


---
Message posted from http://www.ExcelForum.com/

.


Alan Hutchins

Read Only Enforcement
 
I think you have to set the password on the options when
you first save the file (keep the password simple, and
keep a record somewhere)

-----Original Message-----
Is there a way in a macro to force read only?

I see that you can set readonlyRecommended=True.

However, when my users open up the file, they still have

the ability to
open it as normal if they select it with the warning.

What I want to do if force my file to save in readonly

and not let them
open it any other way.

Is there a way to do this when saving the file in the

macro before I
give it to my staff?


---
Message posted from http://www.ExcelForum.com/

.


Vasant Nanavati

Read Only Enforcement
 
Application.DisplayAlerts = False
ThisWorkbook.SaveAs ThisWorkbook.FullName, , , "sesame"
Application.DisplayAlerts = True

should do it.

The user would need the password ("sesame") to override the read-only
requirement.

--

Vasant

"andycharger " wrote in message
...
Is there a way in a macro to force read only?

I see that you can set readonlyRecommended=True.

However, when my users open up the file, they still have the ability to
open it as normal if they select it with the warning.

What I want to do if force my file to save in readonly and not let them
open it any other way.

Is there a way to do this when saving the file in the macro before I
give it to my staff?


---
Message posted from http://www.ExcelForum.com/




andycharger[_11_]

Read Only Enforcement
 
Can you tell me how I disable the Save option in the menu then?
I need to do this either before or during the save of the document
Obviously I dont want to make it part of a macro that runs when a use
opens the file as they can choose to disable macros!

Also you mention the set attr function. Where do I set it and what do
type?


Any ideas

--
Message posted from http://www.ExcelForum.com


Nick Cranham

Read Only Enforcement
 
Andy,
The workbook has a _BeforeSave event, with a Cancel parameter.
That might do the trick.

Password protect the VBA code also, so it cannot be bypassed.

Anyone can still Copy the sheet to a new workbook though, by right clicking
on the sheet tab, so you would need to Hide sheet tabs form the Options and
protect the worksheet also.

NickHK

"andycharger " wrote in message
...
Can you tell me how I disable the Save option in the menu then?
I need to do this either before or during the save of the document.
Obviously I dont want to make it part of a macro that runs when a user
opens the file as they can choose to disable macros!

Also you mention the set attr function. Where do I set it and what do I
type?


Any ideas?


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 04:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com