Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Code based on opening Read Only or not

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Code based on opening Read Only or not

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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Code based on opening Read Only or not

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
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Code based on opening Read Only or not

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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Code based on opening Read Only or not

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" wrote in message
...
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
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
Opening a recommended read only file as non read only Crauwf Excel Programming 2 December 10th 08 08:25 AM
file keeps opening as read only Sal Excel Discussion (Misc queries) 3 November 6th 08 10:43 PM
File always opening as read only Larry Wallis Excel Discussion (Misc queries) 1 February 4th 05 02:22 PM
Opening as Read Only ianripping[_69_] Excel Programming 1 June 19th 04 07:55 PM
opening workbook as read-only Mariusz Excel Programming 2 May 25th 04 08:53 AM


All times are GMT +1. The time now is 06:59 PM.

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

About Us

"It's about Microsoft Excel"