PDA

View Full Version : [SOLVED:] Read Only Prompt When Saving



Jarlisle
12-06-2010, 10:09 AM
I have the following code run when the file is closed:


Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.ScreenUpdating = False
Dim objSheet As Worksheet
'Protecting all worksheets with password
For Each objSheet In Worksheets
If objSheet.ProtectContents = False Then objSheet.Protect "NESAFE", True, True, True, , , , , , , , , , , True, True
Next objSheet
Sheet9.Visible = False
Sheet8.Visible = False
Sheet3.Visible = False
Sheet4.Visible = False
Sheet1.Visible = False
Sheet10.Visible = False
Sheet5.Select
Range("A1").Select
Application.ScreenUpdating = True
Sheet5.Select
Range("A1").Select
ActiveWorkbook.Save
End Sub

Is there a way to only have this run if the file is in edit mode instead of read-only? Also, when it saves at the end it seems to remove my read-only prompt option, is there a way to keep that for the next time someone opens it?

lucas
12-06-2010, 10:27 AM
What does edit mode as opposed to read only mode mean Jarlisle. I copied your code to a blank workbook and added ten sheets. Closed it and it did what your code wanted......

I think we need more info from you to understand your problem....maybe it's just me.

Jarlisle
12-06-2010, 11:32 AM
Sorry, I forgot to say that I added the option to prompt the user to open in read-only (doing so when clicking save as and adding the option). The reason for this is that for some users it's just for information and others need to edit it.

I'm also getting feedback that those that need to edit are not receiving the read-only prompt when opening and can't edit the file.

Sean.DiSanti
12-06-2010, 07:15 PM
for the first part; just check ThisWorkbook.ReadOnly; as far as them not getting the prompt, see if you can recreate the issue. people are so trained to click through dialogs without reading, they may just be continuing read only without thinking about it. also, i'm guessing you have it shared for multiple users to open; i'm not sure what that does to the read only recommendation

Jarlisle
12-06-2010, 09:35 PM
So, I found out that the users I was having issues with were given incorrect permissions to the folder. Also, when it was in read-only it would give an error using the code, but I just put in a check to see if it's read-only as suggested.

Thanks for the help.