Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Stilla
 
Posts: n/a
Default Macro to Protect OK, Unprotect now messed up!

I thought I was being clever in recording a macro to protect workbooks with a
password, and then another to unprotect, using ctrl+ a diff letter everytime.

OK, it works, but now to unprotect I'm not even being asked for password!!
This happens whether I use the macro or the "unprotect" feature from the
menu. As soon as I choose "unprotect" - VOILA! the sheet is unprotected!

Obviously, it sort of defeats the purpose of protecting in the first place,
if anyone can unprotect.

Is this happening, because I'm doing it on the same PC where my macro is
stored?

Help..

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JE McGimpsey
 
Posts: n/a
Default Macro to Protect OK, Unprotect now messed up!

Did you protect the sheets with a password? Like

Sheets("Sheet1").Protect Password:="drowssap"

If not, then the sheet is protected without a password, and you won't be
prompted when you unprotect.

Protecting without a password is still useful - after all, the only
thing protecting actually does is prevent the casual user from screwing
up the worksheet. Anyone with the ability to find these newsgroups can
easily discover a method to bypass worksheet protection:

http://www.mcgimpsey.com/excel/removepwords.html






In article ,
Stilla wrote:

I thought I was being clever in recording a macro to protect workbooks with a
password, and then another to unprotect, using ctrl+ a diff letter everytime.

OK, it works, but now to unprotect I'm not even being asked for password!!
This happens whether I use the macro or the "unprotect" feature from the
menu. As soon as I choose "unprotect" - VOILA! the sheet is unprotected!

Obviously, it sort of defeats the purpose of protecting in the first place,
if anyone can unprotect.

Is this happening, because I'm doing it on the same PC where my macro is
stored?

Help..

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Rowan Drummond
 
Posts: n/a
Default Macro to Protect OK, Unprotect now messed up!

That is because when you record a macro to protect the workbook it does
not automatically record the password. If you go into the vbe your code
will look something like:

Sub Protct()
ActiveWorkbook.Protect Structu=True, Windows:=False
End Sub

change it to:

Sub Protct()
ActiveWorkbook.Protect Structu=True _
, Windows:=False, password:="mypassword"
End Sub

Similarly the macro to unprotect the book should look something like:

Sub Unprtct()
Dim pwd As String
pwd = InputBox("Enter Password...", "Unprotect Book")
If pwd = "mypassword" Then
ActiveWorkbook.Unprotect Password:=pwd
Else
MsgBox "Incorrect Password"
End If
End Sub

And now that you have the password in the VBA code you will probably
want to protect your VBE project so that this can't be viewed. In the
VBE use the menus to goto ToolsVBAProject PropertiesProtection. Check
lock projet for viewing and supply a password.

Hope this helps
Rowan


Stilla wrote:
I thought I was being clever in recording a macro to protect workbooks with a
password, and then another to unprotect, using ctrl+ a diff letter everytime.

OK, it works, but now to unprotect I'm not even being asked for password!!
This happens whether I use the macro or the "unprotect" feature from the
menu. As soon as I choose "unprotect" - VOILA! the sheet is unprotected!

Obviously, it sort of defeats the purpose of protecting in the first place,
if anyone can unprotect.

Is this happening, because I'm doing it on the same PC where my macro is
stored?

Help..

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Stilla
 
Posts: n/a
Default Macro to Protect OK, Unprotect now messed up!

AH HA! I did what you told me and it works! Yeah, I know protection is not
robust.. but it's a whole lot better than nothing!

I am totally new to macros, so let me ask another question...

When I "record" a macro - I am storing it in my Personal Macro worksheet -
(one of the choices). I am doing this instead of attaching the macro to the
file I'm working on, so that when I send this file on email, and someone else
opens it, a) they don't get those pesky security alerts, and 2) they won't be
able to open vba and read my password. IS THIS LOGIC CORRECT?

Thanks for sharing your knowledge!

"JE McGimpsey" wrote:

Did you protect the sheets with a password? Like

Sheets("Sheet1").Protect Password:="drowssap"

If not, then the sheet is protected without a password, and you won't be
prompted when you unprotect.

Protecting without a password is still useful - after all, the only
thing protecting actually does is prevent the casual user from screwing
up the worksheet. Anyone with the ability to find these newsgroups can
easily discover a method to bypass worksheet protection:

http://www.mcgimpsey.com/excel/removepwords.html






In article ,
Stilla wrote:

I thought I was being clever in recording a macro to protect workbooks with a
password, and then another to unprotect, using ctrl+ a diff letter everytime.

OK, it works, but now to unprotect I'm not even being asked for password!!
This happens whether I use the macro or the "unprotect" feature from the
menu. As soon as I choose "unprotect" - VOILA! the sheet is unprotected!

Obviously, it sort of defeats the purpose of protecting in the first place,
if anyone can unprotect.

Is this happening, because I'm doing it on the same PC where my macro is
stored?

Help..

Thanks


  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
wmjenner
 
Posts: n/a
Default Macro to Protect OK, Unprotect now messed up!


Yes your logic is correct. Unless you store the macro in the actual
workbook, it doesn't get sent when you e-mail the file to someone so
they cannot open it. Conversely, I have saved macros that hide and
unhide certain worksheets within a workbook (confidential stuff, for
example) in my personal workbook. If you want to give access to
someone to unhide and rehide, you have to then physically copy the
macro to their own personal workbook (or, if they're not down the hall,
send them the code).


--
wmjenner


------------------------------------------------------------------------
wmjenner's Profile: http://www.excelforum.com/member.php...fo&userid=5282
View this thread: http://www.excelforum.com/showthread...hreadid=491639



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Stilla
 
Posts: n/a
Default Macro to Protect OK, Unprotect now messed up!

Hi ...THANKS... I beginning to understand the macro logic now. I just opened
the file I was working on yesterday, and my "personal macro file" also opened
in the background.

Is this Excel just being nice, or did I do something wrong?

"wmjenner" wrote:


Yes your logic is correct. Unless you store the macro in the actual
workbook, it doesn't get sent when you e-mail the file to someone so
they cannot open it. Conversely, I have saved macros that hide and
unhide certain worksheets within a workbook (confidential stuff, for
example) in my personal workbook. If you want to give access to
someone to unhide and rehide, you have to then physically copy the
macro to their own personal workbook (or, if they're not down the hall,
send them the code).


--
wmjenner


------------------------------------------------------------------------
wmjenner's Profile: http://www.excelforum.com/member.php...fo&userid=5282
View this thread: http://www.excelforum.com/showthread...hreadid=491639


  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Gord Dibben
 
Posts: n/a
Default Macro to Protect OK, Unprotect now messed up!

Stilla

Personal.xls will open when Excel opens.

If you have it set to "hidden" it will open in the background(won't show up on
Window) and your macros will be available for all open workbooks.


Gord Dibben Excel MVP

On Thu, 8 Dec 2005 06:10:06 -0800, Stilla
wrote:

Hi ...THANKS... I beginning to understand the macro logic now. I just opened
the file I was working on yesterday, and my "personal macro file" also opened
in the background.

Is this Excel just being nice, or did I do something wrong?

"wmjenner" wrote:


Yes your logic is correct. Unless you store the macro in the actual
workbook, it doesn't get sent when you e-mail the file to someone so
they cannot open it. Conversely, I have saved macros that hide and
unhide certain worksheets within a workbook (confidential stuff, for
example) in my personal workbook. If you want to give access to
someone to unhide and rehide, you have to then physically copy the
macro to their own personal workbook (or, if they're not down the hall,
send them the code).


--
wmjenner


------------------------------------------------------------------------
wmjenner's Profile: http://www.excelforum.com/member.php...fo&userid=5282
View this thread: http://www.excelforum.com/showthread...hreadid=491639


  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Stilla
 
Posts: n/a
Default Macro to Protect OK, Unprotect now messed up!

THANKS Gord! EXCEL IS SOOOOOOCOOOOL

"Gord Dibben" wrote:

Stilla

Personal.xls will open when Excel opens.

If you have it set to "hidden" it will open in the background(won't show up on
Window) and your macros will be available for all open workbooks.


Gord Dibben Excel MVP

On Thu, 8 Dec 2005 06:10:06 -0800, Stilla
wrote:

Hi ...THANKS... I beginning to understand the macro logic now. I just opened
the file I was working on yesterday, and my "personal macro file" also opened
in the background.

Is this Excel just being nice, or did I do something wrong?

"wmjenner" wrote:


Yes your logic is correct. Unless you store the macro in the actual
workbook, it doesn't get sent when you e-mail the file to someone so
they cannot open it. Conversely, I have saved macros that hide and
unhide certain worksheets within a workbook (confidential stuff, for
example) in my personal workbook. If you want to give access to
someone to unhide and rehide, you have to then physically copy the
macro to their own personal workbook (or, if they're not down the hall,
send them the code).


--
wmjenner


------------------------------------------------------------------------
wmjenner's Profile: http://www.excelforum.com/member.php...fo&userid=5282
View this thread: http://www.excelforum.com/showthread...hreadid=491639



  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3
Default Sub Protct()

Is it possible, and if so how, to keep the characters from showing in the
input box when entered if someone is near and may see the password?

"Rowan Drummond" wrote:

That is because when you record a macro to protect the workbook it does
not automatically record the password. If you go into the vbe your code
will look something like:

Sub Protct()
ActiveWorkbook.Protect Structu=True, Windows:=False
End Sub

change it to:

Sub Protct()
ActiveWorkbook.Protect Structu=True _
, Windows:=False, password:="mypassword"
End Sub

Similarly the macro to unprotect the book should look something like:

Sub Unprtct()
Dim pwd As String
pwd = InputBox("Enter Password...", "Unprotect Book")
If pwd = "mypassword" Then
ActiveWorkbook.Unprotect Password:=pwd
Else
MsgBox "Incorrect Password"
End If
End Sub

And now that you have the password in the VBA code you will probably
want to protect your VBE project so that this can't be viewed. In the
VBE use the menus to goto ToolsVBAProject PropertiesProtection. Check
lock projet for viewing and supply a password.

Hope this helps
Rowan


Stilla wrote:
I thought I was being clever in recording a macro to protect workbooks with a
password, and then another to unprotect, using ctrl+ a diff letter everytime.

OK, it works, but now to unprotect I'm not even being asked for password!!
This happens whether I use the macro or the "unprotect" feature from the
menu. As soon as I choose "unprotect" - VOILA! the sheet is unprotected!

Obviously, it sort of defeats the purpose of protecting in the first place,
if anyone can unprotect.

Is this happening, because I'm doing it on the same PC where my macro is
stored?

Help..

Thanks


  #10   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default Sub Protct()

Not when using an Input Box

You would need a TextBox using PasswordChar probably on a UserForm

See VBA help on passwordchar property.


Gord Dibben MS Excel MVP

On Sun, 4 Jan 2009 10:21:01 -0800, Jarhead19901993
wrote:

Is it possible, and if so how, to keep the characters from showing in the
input box when entered if someone is near and may see the password?

"Rowan Drummond" wrote:

That is because when you record a macro to protect the workbook it does
not automatically record the password. If you go into the vbe your code
will look something like:

Sub Protct()
ActiveWorkbook.Protect Structu=True, Windows:=False
End Sub

change it to:

Sub Protct()
ActiveWorkbook.Protect Structu=True _
, Windows:=False, password:="mypassword"
End Sub

Similarly the macro to unprotect the book should look something like:

Sub Unprtct()
Dim pwd As String
pwd = InputBox("Enter Password...", "Unprotect Book")
If pwd = "mypassword" Then
ActiveWorkbook.Unprotect Password:=pwd
Else
MsgBox "Incorrect Password"
End If
End Sub

And now that you have the password in the VBA code you will probably
want to protect your VBE project so that this can't be viewed. In the
VBE use the menus to goto ToolsVBAProject PropertiesProtection. Check
lock projet for viewing and supply a password.

Hope this helps
Rowan


Stilla wrote:
I thought I was being clever in recording a macro to protect workbooks with a
password, and then another to unprotect, using ctrl+ a diff letter everytime.

OK, it works, but now to unprotect I'm not even being asked for password!!
This happens whether I use the macro or the "unprotect" feature from the
menu. As soon as I choose "unprotect" - VOILA! the sheet is unprotected!

Obviously, it sort of defeats the purpose of protecting in the first place,
if anyone can unprotect.

Is this happening, because I'm doing it on the same PC where my macro is
stored?

Help..

Thanks





  #11   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3
Default Sub Protct()

Are there examples of the code necessary? I have seen links in other posts,
but all of the sites I've uncovered links to linking to Daniel Klann who
wrote code for this purpose appear to no longer function.

"Gord Dibben" wrote:

Not when using an Input Box

You would need a TextBox using PasswordChar probably on a UserForm

See VBA help on passwordchar property.


Gord Dibben MS Excel MVP

On Sun, 4 Jan 2009 10:21:01 -0800, Jarhead19901993
wrote:

Is it possible, and if so how, to keep the characters from showing in the
input box when entered if someone is near and may see the password?

"Rowan Drummond" wrote:

That is because when you record a macro to protect the workbook it does
not automatically record the password. If you go into the vbe your code
will look something like:

Sub Protct()
ActiveWorkbook.Protect Structu=True, Windows:=False
End Sub

change it to:

Sub Protct()
ActiveWorkbook.Protect Structu=True _
, Windows:=False, password:="mypassword"
End Sub

Similarly the macro to unprotect the book should look something like:

Sub Unprtct()
Dim pwd As String
pwd = InputBox("Enter Password...", "Unprotect Book")
If pwd = "mypassword" Then
ActiveWorkbook.Unprotect Password:=pwd
Else
MsgBox "Incorrect Password"
End If
End Sub

And now that you have the password in the VBA code you will probably
want to protect your VBE project so that this can't be viewed. In the
VBE use the menus to goto ToolsVBAProject PropertiesProtection. Check
lock projet for viewing and supply a password.

Hope this helps
Rowan


Stilla wrote:
I thought I was being clever in recording a macro to protect workbooks with a
password, and then another to unprotect, using ctrl+ a diff letter everytime.

OK, it works, but now to unprotect I'm not even being asked for password!!
This happens whether I use the macro or the "unprotect" feature from the
menu. As soon as I choose "unprotect" - VOILA! the sheet is unprotected!

Obviously, it sort of defeats the purpose of protecting in the first place,
if anyone can unprotect.

Is this happening, because I'm doing it on the same PC where my macro is
stored?

Help..

Thanks



  #12   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default Sub Protct()

A sample from Dave Peterson using a textbox on a UserForm.

Private Sub CommandButton1_Click()
Dim myPwd As String
myPwd = "ok"
UserForm1.MultiPage1.Pages("admin").Visible _
= CBool(Me.TextBox1.Value = myPwd)
Unload Me
End Sub

Private Sub UserForm_Initialize()
Me.TextBox1.PasswordChar = "*"
End Sub


Gord

On Tue, 6 Jan 2009 03:30:01 -0800, Jarhead19901993
wrote:

Are there examples of the code necessary? I have seen links in other posts,
but all of the sites I've uncovered links to linking to Daniel Klann who
wrote code for this purpose appear to no longer function.

"Gord Dibben" wrote:

Not when using an Input Box

You would need a TextBox using PasswordChar probably on a UserForm

See VBA help on passwordchar property.


Gord Dibben MS Excel MVP

On Sun, 4 Jan 2009 10:21:01 -0800, Jarhead19901993
wrote:

Is it possible, and if so how, to keep the characters from showing in the
input box when entered if someone is near and may see the password?

"Rowan Drummond" wrote:

That is because when you record a macro to protect the workbook it does
not automatically record the password. If you go into the vbe your code
will look something like:

Sub Protct()
ActiveWorkbook.Protect Structu=True, Windows:=False
End Sub

change it to:

Sub Protct()
ActiveWorkbook.Protect Structu=True _
, Windows:=False, password:="mypassword"
End Sub

Similarly the macro to unprotect the book should look something like:

Sub Unprtct()
Dim pwd As String
pwd = InputBox("Enter Password...", "Unprotect Book")
If pwd = "mypassword" Then
ActiveWorkbook.Unprotect Password:=pwd
Else
MsgBox "Incorrect Password"
End If
End Sub

And now that you have the password in the VBA code you will probably
want to protect your VBE project so that this can't be viewed. In the
VBE use the menus to goto ToolsVBAProject PropertiesProtection. Check
lock projet for viewing and supply a password.

Hope this helps
Rowan


Stilla wrote:
I thought I was being clever in recording a macro to protect workbooks with a
password, and then another to unprotect, using ctrl+ a diff letter everytime.

OK, it works, but now to unprotect I'm not even being asked for password!!
This happens whether I use the macro or the "unprotect" feature from the
menu. As soon as I choose "unprotect" - VOILA! the sheet is unprotected!

Obviously, it sort of defeats the purpose of protecting in the first place,
if anyone can unprotect.

Is this happening, because I'm doing it on the same PC where my macro is
stored?

Help..

Thanks




  #13   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3
Default Sub Protct()

Thank you for your help.

Rick

"Gord Dibben" wrote:

A sample from Dave Peterson using a textbox on a UserForm.

Private Sub CommandButton1_Click()
Dim myPwd As String
myPwd = "ok"
UserForm1.MultiPage1.Pages("admin").Visible _
= CBool(Me.TextBox1.Value = myPwd)
Unload Me
End Sub

Private Sub UserForm_Initialize()
Me.TextBox1.PasswordChar = "*"
End Sub


Gord

On Tue, 6 Jan 2009 03:30:01 -0800, Jarhead19901993
wrote:

Are there examples of the code necessary? I have seen links in other posts,
but all of the sites I've uncovered links to linking to Daniel Klann who
wrote code for this purpose appear to no longer function.

"Gord Dibben" wrote:

Not when using an Input Box

You would need a TextBox using PasswordChar probably on a UserForm

See VBA help on passwordchar property.


Gord Dibben MS Excel MVP

On Sun, 4 Jan 2009 10:21:01 -0800, Jarhead19901993
wrote:

Is it possible, and if so how, to keep the characters from showing in the
input box when entered if someone is near and may see the password?

"Rowan Drummond" wrote:

That is because when you record a macro to protect the workbook it does
not automatically record the password. If you go into the vbe your code
will look something like:

Sub Protct()
ActiveWorkbook.Protect Structu=True, Windows:=False
End Sub

change it to:

Sub Protct()
ActiveWorkbook.Protect Structu=True _
, Windows:=False, password:="mypassword"
End Sub

Similarly the macro to unprotect the book should look something like:

Sub Unprtct()
Dim pwd As String
pwd = InputBox("Enter Password...", "Unprotect Book")
If pwd = "mypassword" Then
ActiveWorkbook.Unprotect Password:=pwd
Else
MsgBox "Incorrect Password"
End If
End Sub

And now that you have the password in the VBA code you will probably
want to protect your VBE project so that this can't be viewed. In the
VBE use the menus to goto ToolsVBAProject PropertiesProtection. Check
lock projet for viewing and supply a password.

Hope this helps
Rowan


Stilla wrote:
I thought I was being clever in recording a macro to protect workbooks with a
password, and then another to unprotect, using ctrl+ a diff letter everytime.

OK, it works, but now to unprotect I'm not even being asked for password!!
This happens whether I use the macro or the "unprotect" feature from the
menu. As soon as I choose "unprotect" - VOILA! the sheet is unprotected!

Obviously, it sort of defeats the purpose of protecting in the first place,
if anyone can unprotect.

Is this happening, because I'm doing it on the same PC where my macro is
stored?

Help..

Thanks





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
Editing a simple macro Connie Martin Excel Worksheet Functions 5 November 29th 05 09:19 PM
Closing File Error jcliquidtension Excel Discussion (Misc queries) 4 October 20th 05 12:22 PM
How to protect and unprotect 30 worksheets in a file every month . Protect & Unprotect Several Worksheets Excel Worksheet Functions 4 January 10th 05 01:29 PM
Is there any way that you can protect or unprotect a group of wor. CheriT63 Excel Discussion (Misc queries) 9 January 8th 05 08:40 PM
How to protect my macro Protect & Unprotect Several Worksheets Excel Discussion (Misc queries) 1 January 7th 05 02:01 AM


All times are GMT +1. The time now is 10:45 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"