Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 191
Default code to unprotect sheet with password

I need to run a macro that first unprotects a password protected sheet, and
then reprotects it later, with a password. The user will not know the
password, and therefore the code needs to, itself, have it hardcoded in
there. I am not concerned about someone digging in the code and finding the
password, so assume that's not an issue.

Is this possible, and if so, what is the code?

Thanks.
--
Boris
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default code to unprotect sheet with password

You can get this by recording the macro (often a good way to get a look
at possible code choices) but it's

activesheet.unprotect password="fred"
BorisS wrote:
I need to run a macro that first unprotects a password protected sheet, and
then reprotects it later, with a password. The user will not know the
password, and therefore the code needs to, itself, have it hardcoded in
there. I am not concerned about someone digging in the code and finding the
password, so assume that's not an issue.

Is this possible, and if so, what is the code?

Thanks.
--
Boris


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 191
Default code to unprotect sheet with password

that's always my first try, but it doesn't record the password ones, I
believe. At least I tried it, and it didn't.

One other thing I needed was for it to be specific about only selecting
(2003 version) the ability to select unlocked cells. It usually defaults to
having selection of both locked and unlocked checked. Is there any way to
indicate this in the code?

The code that recorded when I tried this was:
ActiveSheet.protect DrawingObjects:=True, Contents:=True, Scenarios:=True

Thanks for any further help.
--
Boris


" wrote:

You can get this by recording the macro (often a good way to get a look
at possible code choices) but it's

activesheet.unprotect password="fred"
BorisS wrote:
I need to run a macro that first unprotects a password protected sheet, and
then reprotects it later, with a password. The user will not know the
password, and therefore the code needs to, itself, have it hardcoded in
there. I am not concerned about someone digging in the code and finding the
password, so assume that's not an issue.

Is this possible, and if so, what is the code?

Thanks.
--
Boris



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default code to unprotect sheet with password

You are right about the password of course - I should have said, having
recorded the macro, use F1 to get help about what you see - but anyway

ActiveSheet.EnableSelection = xlUnlockedCells

should do what you want (I think) - oh, and this bit WAS recorded!


BorisS wrote:
that's always my first try, but it doesn't record the password ones, I
believe. At least I tried it, and it didn't.

One other thing I needed was for it to be specific about only selecting
(2003 version) the ability to select unlocked cells. It usually defaults to
having selection of both locked and unlocked checked. Is there any way to
indicate this in the code?

The code that recorded when I tried this was:
ActiveSheet.protect DrawingObjects:=True, Contents:=True, Scenarios:=True

Thanks for any further help.
--
Boris


" wrote:

You can get this by recording the macro (often a good way to get a look
at possible code choices) but it's

activesheet.unprotect password="fred"
BorisS wrote:
I need to run a macro that first unprotects a password protected sheet, and
then reprotects it later, with a password. The user will not know the
password, and therefore the code needs to, itself, have it hardcoded in
there. I am not concerned about someone digging in the code and finding the
password, so assume that's not an issue.

Is this possible, and if so, what is the code?

Thanks.
--
Boris




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 191
Default code to unprotect sheet with password

Sorry for sounding stupid, but now I am confused.

It sounds like the two pieces I have are how to unprotect with password, and
then how to enable the selection only of unlocked cells. But does the second
piece you gave (the one that enables the selection only of unlocked cells
ALSO protect it, with the same password?

The three steps I need a

1) unprotect (which I think I have from the first response)
some code which I have which will operate in here
2) enabling of selecting only unlocked cells once protected
3) protection with password (use "test" as example)

I have tried to put the following code in (based on what you'd sent, and
what I was guessing would protect it:

ActiveSheet.Unprotect Password = "test"
ActiveSheet.EnableSelection = xlUnlockedCells
ActiveSheet.protect passwords = "test"

and this stops at the first line, which was the one that you'd suggested in
the first message. Am I doing something wrong?
--
Boris


" wrote:

You are right about the password of course - I should have said, having
recorded the macro, use F1 to get help about what you see - but anyway

ActiveSheet.EnableSelection = xlUnlockedCells

should do what you want (I think) - oh, and this bit WAS recorded!


BorisS wrote:
that's always my first try, but it doesn't record the password ones, I
believe. At least I tried it, and it didn't.

One other thing I needed was for it to be specific about only selecting
(2003 version) the ability to select unlocked cells. It usually defaults to
having selection of both locked and unlocked checked. Is there any way to
indicate this in the code?

The code that recorded when I tried this was:
ActiveSheet.protect DrawingObjects:=True, Contents:=True, Scenarios:=True

Thanks for any further help.
--
Boris


" wrote:

You can get this by recording the macro (often a good way to get a look
at possible code choices) but it's

activesheet.unprotect password="fred"
BorisS wrote:
I need to run a macro that first unprotects a password protected sheet, and
then reprotects it later, with a password. The user will not know the
password, and therefore the code needs to, itself, have it hardcoded in
there. I am not concerned about someone digging in the code and finding the
password, so assume that's not an issue.

Is this possible, and if so, what is the code?

Thanks.
--
Boris






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default code to unprotect sheet with password

I must admit I was a bit confused with the order of what I'd recorded,
as the selection of unlocked only cells was set AFTER the password -
having done a quick test, it doesn't matter which way round it's run -
each line is independant and the password setting bit will set the
password, the unlocked cells only being selected bit will allow only
unlocked cells to be selected! You do need BOTH lines though.


BorisS wrote:
Sorry for sounding stupid, but now I am confused.

It sounds like the two pieces I have are how to unprotect with password, and
then how to enable the selection only of unlocked cells. But does the second
piece you gave (the one that enables the selection only of unlocked cells
ALSO protect it, with the same password?

The three steps I need a

1) unprotect (which I think I have from the first response)
some code which I have which will operate in here
2) enabling of selecting only unlocked cells once protected
3) protection with password (use "test" as example)

I have tried to put the following code in (based on what you'd sent, and
what I was guessing would protect it:

ActiveSheet.Unprotect Password = "test"
ActiveSheet.EnableSelection = xlUnlockedCells
ActiveSheet.protect passwords = "test"

and this stops at the first line, which was the one that you'd suggested in
the first message. Am I doing something wrong?
--
Boris


" wrote:

You are right about the password of course - I should have said, having
recorded the macro, use F1 to get help about what you see - but anyway

ActiveSheet.EnableSelection = xlUnlockedCells

should do what you want (I think) - oh, and this bit WAS recorded!


BorisS wrote:
that's always my first try, but it doesn't record the password ones, I
believe. At least I tried it, and it didn't.

One other thing I needed was for it to be specific about only selecting
(2003 version) the ability to select unlocked cells. It usually defaults to
having selection of both locked and unlocked checked. Is there any way to
indicate this in the code?

The code that recorded when I tried this was:
ActiveSheet.protect DrawingObjects:=True, Contents:=True, Scenarios:=True

Thanks for any further help.
--
Boris


" wrote:

You can get this by recording the macro (often a good way to get a look
at possible code choices) but it's

activesheet.unprotect password="fred"
BorisS wrote:
I need to run a macro that first unprotects a password protected sheet, and
then reprotects it later, with a password. The user will not know the
password, and therefore the code needs to, itself, have it hardcoded in
there. I am not concerned about someone digging in the code and finding the
password, so assume that's not an issue.

Is this possible, and if so, what is the code?

Thanks.
--
Boris





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
I need to unprotect sheet so I cn sve it but need a password? scout ron Excel Discussion (Misc queries) 2 May 28th 10 03:05 PM
Code to protect/unprotect a sheet using a macro with password FredH Excel Discussion (Misc queries) 5 October 23rd 07 04:49 PM
Unprotect Sheet Password in Macros Theresa Excel Programming 4 April 2nd 06 01:51 PM
Please help!!! Using code to password-protect and unprotect... Hawk Excel Programming 6 July 9th 05 10:48 PM
Protect/unprotect sheet with password with VBA? dragontale[_7_] Excel Programming 1 April 19th 04 09:29 PM


All times are GMT +1. The time now is 05:31 AM.

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"