#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,814
Default 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,

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default 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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,814
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Read only file is NOT Read only Marilyn Excel Discussion (Misc queries) 1 November 18th 08 05:22 AM
I have a read only xl file, I need it to be read and write drama queen Excel Discussion (Misc queries) 3 July 1st 06 12:25 AM
Read-write/Read-only Jillian Excel Discussion (Misc queries) 4 February 16th 06 05:26 PM
XCEL FILE REC'D AS READ ONLY -- HOW TO NOT BE "READ ONLY" billybob Excel Discussion (Misc queries) 1 February 13th 06 03:14 AM
How can a file be converted from Read-Only to Read/Write Jim in Apopka Excel Discussion (Misc queries) 2 November 19th 05 04:59 PM


All times are GMT +1. The time now is 12:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"