PC Review


Reply
Thread Tools Rate Thread

Allowing users to run macros on protected worksheets

 
 
=?Utf-8?B?U0RVTkZPUkQ=?=
Guest
Posts: n/a
 
      30th Jan 2007
I am trying to allow users of my workbook to run macros on protected
worksheets. I have tried using the following code:
Private Sub Workbook_Open()
Dim wSheet As Worksheet

For Each wSheet In Worksheets
wSheet.Protect Password:="Secret", _
UserInterFaceOnly:=True
Next wSheet
End Sub

When I then open the workbook, it says that the password I provided is
incorrect. I changed the "Secret" password to the correct one and that
didn't work. I also tried using "Secret" as the password to protect the
worksheets and that still didn't work. Does anyone have any suggestions or a
different way to do this?

 
Reply With Quote
 
 
 
 
Alan
Guest
Posts: n/a
 
      30th Jan 2007
If you are trying to unprotect the worksheets on Open, why are they
protected?

Including a module in every Workbook increases the file size of the file,
increasing costs for the company, in storage. This is compounded when you
have multiple users saving off individual copies of the same file.

I would suggest that the user macros include the code to UnProtect the
worksheets. Include this code at the beginning of each macros your users are
running:

Dim wSheet As Worksheet
For Each wSheet In Worksheets
wSheet.UnProtect Password:="Secret"
Next wSheet


Include this at the end of the user macros:


For Each wSheet In Worksheets
wSheet.Protect Password:="Secret", _
UserInterFaceOnly:=True
Next wSheet

This way, the sheets are only UnProtected when user macro runs, and
protected when user macro completes.

If you want the file contain the module, then change "Protect" to
"UnProtect" and remove "UserInterFaceOnly:=True". The worksheets will remain
unprotected unless you put more code in it to reprotect the sheets on a
workbook close event. Again, you are increasing the file size even more.

Alan


"The only dumb question is a question left unasked."


"SDUNFORD" <(E-Mail Removed)> wrote in message
news:E2FBF42A-B5F5-40C4-AEC1-(E-Mail Removed)...
>I am trying to allow users of my workbook to run macros on protected
> worksheets. I have tried using the following code:
> Private Sub Workbook_Open()
> Dim wSheet As Worksheet
>
> For Each wSheet In Worksheets
> wSheet.Protect Password:="Secret", _
> UserInterFaceOnly:=True
> Next wSheet
> End Sub
>
> When I then open the workbook, it says that the password I provided is
> incorrect. I changed the "Secret" password to the correct one and that
> didn't work. I also tried using "Secret" as the password to protect the
> worksheets and that still didn't work. Does anyone have any suggestions
> or a
> different way to do this?
>



 
Reply With Quote
 
=?Utf-8?B?U0RVTkZPUkQ=?=
Guest
Posts: n/a
 
      30th Jan 2007
Thanks!!

"Alan" wrote:

> If you are trying to unprotect the worksheets on Open, why are they
> protected?
>
> Including a module in every Workbook increases the file size of the file,
> increasing costs for the company, in storage. This is compounded when you
> have multiple users saving off individual copies of the same file.
>
> I would suggest that the user macros include the code to UnProtect the
> worksheets. Include this code at the beginning of each macros your users are
> running:
>
> Dim wSheet As Worksheet
> For Each wSheet In Worksheets
> wSheet.UnProtect Password:="Secret"
> Next wSheet
>
>
> Include this at the end of the user macros:
>
>
> For Each wSheet In Worksheets
> wSheet.Protect Password:="Secret", _
> UserInterFaceOnly:=True
> Next wSheet
>
> This way, the sheets are only UnProtected when user macro runs, and
> protected when user macro completes.
>
> If you want the file contain the module, then change "Protect" to
> "UnProtect" and remove "UserInterFaceOnly:=True". The worksheets will remain
> unprotected unless you put more code in it to reprotect the sheets on a
> workbook close event. Again, you are increasing the file size even more.
>
> Alan
>
>
> "The only dumb question is a question left unasked."
>
>
> "SDUNFORD" <(E-Mail Removed)> wrote in message
> news:E2FBF42A-B5F5-40C4-AEC1-(E-Mail Removed)...
> >I am trying to allow users of my workbook to run macros on protected
> > worksheets. I have tried using the following code:
> > Private Sub Workbook_Open()
> > Dim wSheet As Worksheet
> >
> > For Each wSheet In Worksheets
> > wSheet.Protect Password:="Secret", _
> > UserInterFaceOnly:=True
> > Next wSheet
> > End Sub
> >
> > When I then open the workbook, it says that the password I provided is
> > incorrect. I changed the "Secret" password to the correct one and that
> > didn't work. I also tried using "Secret" as the password to protect the
> > worksheets and that still didn't work. Does anyone have any suggestions
> > or a
> > different way to do this?
> >

>
>
>

 
Reply With Quote
 
Alan
Guest
Posts: n/a
 
      30th Jan 2007
Your welcome.


"SDUNFORD" <(E-Mail Removed)> wrote in message
news:14EE7AD5-B4D1-4C9F-84ED-(E-Mail Removed)...
> Thanks!!
>
> "Alan" wrote:
>
>> If you are trying to unprotect the worksheets on Open, why are they
>> protected?
>>
>> Including a module in every Workbook increases the file size of the file,
>> increasing costs for the company, in storage. This is compounded when you
>> have multiple users saving off individual copies of the same file.
>>
>> I would suggest that the user macros include the code to UnProtect the
>> worksheets. Include this code at the beginning of each macros your users
>> are
>> running:
>>
>> Dim wSheet As Worksheet
>> For Each wSheet In Worksheets
>> wSheet.UnProtect Password:="Secret"
>> Next wSheet
>>
>>
>> Include this at the end of the user macros:
>>
>>
>> For Each wSheet In Worksheets
>> wSheet.Protect Password:="Secret", _
>> UserInterFaceOnly:=True
>> Next wSheet
>>
>> This way, the sheets are only UnProtected when user macro runs, and
>> protected when user macro completes.
>>
>> If you want the file contain the module, then change "Protect" to
>> "UnProtect" and remove "UserInterFaceOnly:=True". The worksheets will
>> remain
>> unprotected unless you put more code in it to reprotect the sheets on a
>> workbook close event. Again, you are increasing the file size even more.
>>
>> Alan
>>
>>
>> "The only dumb question is a question left unasked."
>>
>>
>> "SDUNFORD" <(E-Mail Removed)> wrote in message
>> news:E2FBF42A-B5F5-40C4-AEC1-(E-Mail Removed)...
>> >I am trying to allow users of my workbook to run macros on protected
>> > worksheets. I have tried using the following code:
>> > Private Sub Workbook_Open()
>> > Dim wSheet As Worksheet
>> >
>> > For Each wSheet In Worksheets
>> > wSheet.Protect Password:="Secret", _
>> > UserInterFaceOnly:=True
>> > Next wSheet
>> > End Sub
>> >
>> > When I then open the workbook, it says that the password I provided is
>> > incorrect. I changed the "Secret" password to the correct one and that
>> > didn't work. I also tried using "Secret" as the password to protect
>> > the
>> > worksheets and that still didn't work. Does anyone have any
>> > suggestions
>> > or a
>> > different way to do this?
>> >

>>
>>
>>



 
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
Allowing Chart creation in protected worksheets sheets using VB co =?Utf-8?B?QW50aG9ueSBIYXJkaW5n?= Microsoft Excel Programming 4 9th May 2007 09:10 PM
Allowing users to add comments to cells on protected sheets scottchampion@gmail.com Microsoft Excel Discussion 0 15th Nov 2006 12:05 AM
How can I lock worksheets while still allowing macros to operate? =?Utf-8?B?ZW5naW5ndXZlbg==?= Microsoft Excel Misc 2 9th Jan 2006 10:06 PM
How can I lock worksheets while still allowing macros to operate? =?Utf-8?B?ZW5naW5ndXZlbg==?= Microsoft Excel Misc 1 9th Jan 2006 09:47 PM
Allowing spell check on protected worksheets =?Utf-8?B?QWxsb3dpbmcgc3BlbGwgY2hlY2sgb24gcHJvdGVj Microsoft Excel Setup 1 8th Feb 2005 07:13 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:08 AM.