![]() |
Read Only
Good day. I have an Excel file that I want to give the users an option of
opening Read Only or open for edit. I don't want to do this through a desktop shortcut, but rather through VBA. Is there any VBA code that will allow this, or can I make a file read only once it is opened using "ReadOnly:=True" or something of that nature. Thanks, |
Read Only
Maybe you could do this:
Save your file with "readonly recommended" checked. File|SaveAs|tools|general options|check that "read-only recommended" box. Then the user will be prompted each time they open it. ==== If you really want VBA (I wouldn't!) since macros can be disabled. You could ask after the workbook is opened. Option Explicit Sub auto_open() Dim resp As Long If ThisWorkbook.ReadOnly = True Then 'they opened it readonly 'do nothing Else resp = MsgBox(Prompt:="What to change it to readonly?", _ Buttons:=vbYesNo) If resp = vbYes Then ThisWorkbook.ChangeFileAccess xlReadOnly End If End If End Sub Steve wrote: Good day. I have an Excel file that I want to give the users an option of opening Read Only or open for edit. I don't want to do this through a desktop shortcut, but rather through VBA. Is there any VBA code that will allow this, or can I make a file read only once it is opened using "ReadOnly:=True" or something of that nature. Thanks, -- Dave Peterson |
Read Only
Thank you Dave, just what I needed.
"Dave Peterson" wrote: Maybe you could do this: Save your file with "readonly recommended" checked. File|SaveAs|tools|general options|check that "read-only recommended" box. Then the user will be prompted each time they open it. ==== If you really want VBA (I wouldn't!) since macros can be disabled. You could ask after the workbook is opened. Option Explicit Sub auto_open() Dim resp As Long If ThisWorkbook.ReadOnly = True Then 'they opened it readonly 'do nothing Else resp = MsgBox(Prompt:="What to change it to readonly?", _ Buttons:=vbYesNo) If resp = vbYes Then ThisWorkbook.ChangeFileAccess xlReadOnly End If End If End Sub Steve wrote: Good day. I have an Excel file that I want to give the users an option of opening Read Only or open for edit. I don't want to do this through a desktop shortcut, but rather through VBA. Is there any VBA code that will allow this, or can I make a file read only once it is opened using "ReadOnly:=True" or something of that nature. Thanks, -- Dave Peterson |
All times are GMT +1. The time now is 06:03 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com