PC Review


Reply
Thread Tools Rate Thread

Code based on opening Read Only or not

 
 
Craig
Guest
Posts: n/a
 
      29th Oct 2009
Hi

When a user opens my file they see the standard password box in which they
can either click the Read Only button and work in it as Read Only or enter
the password and work in it with write access.

Is there macro code I can enter in the same file that would hide a group of
worksheets if the user opens that file with write access but would not hide
these worksheets if they open the file as Read only?

thank you very much.....Craig

 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      29th Oct 2009
You could use the Auto_Open() procedure in a General module:

Option Explicit
Sub auto_open()
If ThisWorkbook.ReadOnly Then
'do what you want
Else
'do something else
End If
End Sub

Or the Workbook_Open() event in the ThisWorkbook:

Option Explicit
Sub Workbook_Open()
If Me.ReadOnly Then
'do what you want
Else
'do something else
End If
End Sub

Craig wrote:
>
> Hi
>
> When a user opens my file they see the standard password box in which they
> can either click the Read Only button and work in it as Read Only or enter
> the password and work in it with write access.
>
> Is there macro code I can enter in the same file that would hide a group of
> worksheets if the user opens that file with write access but would not hide
> these worksheets if they open the file as Read only?
>
> thank you very much.....Craig


--

Dave Peterson
 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      29th Oct 2009
Ps. The user will have to allow macros to run for those to work.

Craig wrote:
>
> Hi
>
> When a user opens my file they see the standard password box in which they
> can either click the Read Only button and work in it as Read Only or enter
> the password and work in it with write access.
>
> Is there macro code I can enter in the same file that would hide a group of
> worksheets if the user opens that file with write access but would not hide
> these worksheets if they open the file as Read only?
>
> thank you very much.....Craig


--

Dave Peterson
 
Reply With Quote
 
Barb Reinhardt
Guest
Posts: n/a
 
      29th Oct 2009
If you are referring to your opened workbook as oWB, use something like this

if oWB.ReadOnly then
'Do read only stuff
else
'Do edit stuff
End if

HTH,
Barb Reinhardt

"Craig" wrote:

> Hi
>
> When a user opens my file they see the standard password box in which they
> can either click the Read Only button and work in it as Read Only or enter
> the password and work in it with write access.
>
> Is there macro code I can enter in the same file that would hide a group of
> worksheets if the user opens that file with write access but would not hide
> these worksheets if they open the file as Read only?
>
> thank you very much.....Craig
>

 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      29th Oct 2009
I guess the OP could start the workbook with the group of sheets hidden and
the workbook password protected. Then, when the workbook is opened, he could
check to see if it is read-only or not... if it is not read only, he could
unhide those sheets. When the workbook is closed, he could re-hide the
sheets and re-apply the password protection. I guess to stop anyone from
discovering the embedded password, he would have to come up with an
encryption/decryption algorithm to make it harder to figure out what the
password is.

--
Rick (MVP - Excel)


"Dave Peterson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Ps. The user will have to allow macros to run for those to work.
>
> Craig wrote:
>>
>> Hi
>>
>> When a user opens my file they see the standard password box in which
>> they
>> can either click the Read Only button and work in it as Read Only or
>> enter
>> the password and work in it with write access.
>>
>> Is there macro code I can enter in the same file that would hide a group
>> of
>> worksheets if the user opens that file with write access but would not
>> hide
>> these worksheets if they open the file as Read only?
>>
>> thank you very much.....Craig

>
> --
>
> Dave Peterson


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Making Form Read only based on Windows User - Code correction requ Irshad Alam Microsoft Access VBA Modules 1 22nd May 2010 04:58 PM
Opening a recommended read only file as non read only Crauwf Microsoft Excel Programming 2 10th Dec 2008 08:25 AM
Run VBA code only worksheet change, but don't trigger worksheet_change event based on what the code does ker_01 Microsoft Excel Programming 6 3rd Oct 2008 09:45 PM
Document opening as read only when it hasn't been saved as read on =?Utf-8?B?QmFyYmFyYQ==?= Microsoft Word Document Management 0 16th Nov 2005 11:06 AM
OLK2K3: "Read page" code not firing when opening or clicking cmdBu =?Utf-8?B?QmlsbCBCaWxsbWlyZQ==?= Microsoft Outlook Form Programming 4 9th Dec 2004 10:21 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:13 PM.