Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 407
Default Password reused

Yes, that PW protection of macros does the trick. I should always use this
since a user inadvertently editing a macro can be a disaster. But I have a
question: If the macro crashes, can they still go into debug and tell me
where it crashed? Or do they lose that visibility? If so, I guess they can
just e-mail me the file, but they prefer an instantaneous fix!

Thanks so much, Dave.

Dean

"Dave Peterson" wrote in message
...
You can protect the code in your project.

Inside the VBE
tools|VBAProject Properties|Protection tab
Give it a nice, memorable password and check the lock project for viewing
box.

Save and close your workbook and you'll see that the code can't be seen by
the
average user.

Be aware that there are ways to break this protection--as well as ways to
just
unprotect worksheets. So don't assume your data is safe from prying eyes.

If you really wanted a macro that prompted you for a single password:

Option Explicit
Sub testme()
Dim wks As Worksheet
Dim myPWD As String
Dim iCtr As Long

myPWD = InputBox(Prompt:="Enter the common password")

If myPWD = "" Then
Exit Sub
End If

For iCtr = 1 To 3 'worksheets.count
Set wks = Worksheets(iCtr)
With wks
If .ProtectContents = True _
Or .ProtectDrawingObjects = True _
Or .ProtectScenarios = True Then
On Error Resume Next
.Unprotect Password:=myPWD
If Err.Number < 0 Then
MsgBox "not the correct password for: " & .Name
Err.Clear
End If
End If
End With
Next iCtr

End Sub

ps. This is a text only newsgroup. Please post in plain text--not HTML.

Dean wrote:

I use the same password to protect all worksheets. I want to be able to
protect all sheets (or unprotect all sheets) with the password, via a
macro.
But I don't want someone to be able to find the password in the text of a
macro. So, I guess a compromise is to have it ask me for the password
once,
but then reuse that answer for all the other worksheets it then protects
(or
unprotects). Can someone give me some code that would unprotect sheets 1
through 3 with the password "joe", in this manner, i.e., entered by the
user
only once?

Thanks!
Dean


--

Dave Peterson



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Password reused

If the project is protected from viewing, then that includes after crashes, too.

Dean wrote:

Yes, that PW protection of macros does the trick. I should always use this
since a user inadvertently editing a macro can be a disaster. But I have a
question: If the macro crashes, can they still go into debug and tell me
where it crashed? Or do they lose that visibility? If so, I guess they can
just e-mail me the file, but they prefer an instantaneous fix!

Thanks so much, Dave.

Dean

"Dave Peterson" wrote in message
...
You can protect the code in your project.

Inside the VBE
tools|VBAProject Properties|Protection tab
Give it a nice, memorable password and check the lock project for viewing
box.

Save and close your workbook and you'll see that the code can't be seen by
the
average user.

Be aware that there are ways to break this protection--as well as ways to
just
unprotect worksheets. So don't assume your data is safe from prying eyes.

If you really wanted a macro that prompted you for a single password:

Option Explicit
Sub testme()
Dim wks As Worksheet
Dim myPWD As String
Dim iCtr As Long

myPWD = InputBox(Prompt:="Enter the common password")

If myPWD = "" Then
Exit Sub
End If

For iCtr = 1 To 3 'worksheets.count
Set wks = Worksheets(iCtr)
With wks
If .ProtectContents = True _
Or .ProtectDrawingObjects = True _
Or .ProtectScenarios = True Then
On Error Resume Next
.Unprotect Password:=myPWD
If Err.Number < 0 Then
MsgBox "not the correct password for: " & .Name
Err.Clear
End If
End If
End With
Next iCtr

End Sub

ps. This is a text only newsgroup. Please post in plain text--not HTML.

Dean wrote:

I use the same password to protect all worksheets. I want to be able to
protect all sheets (or unprotect all sheets) with the password, via a
macro.
But I don't want someone to be able to find the password in the text of a
macro. So, I guess a compromise is to have it ask me for the password
once,
but then reuse that answer for all the other worksheets it then protects
(or
unprotects). Can someone give me some code that would unprotect sheets 1
through 3 with the password "joe", in this manner, i.e., entered by the
user
only once?

Thanks!
Dean


--

Dave Peterson


--

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
PASSWORD REMOVAL I have the password to open the file and the password to modify the file now how to remove them LJ[_4_] Excel Programming 0 April 27th 06 03:18 AM
how to automate opening a password protected excel file? e.g. a .xls that has a password set in the security tab. Daniel Excel Worksheet Functions 0 June 23rd 05 11:56 PM
bypass password when update linking of password protected file Yan Excel Discussion (Misc queries) 1 February 7th 05 11:29 PM
Excel password but cant hide the sheets before entering password cakonopka[_3_] Excel Programming 1 January 30th 04 06:28 PM
VBa, Password protected sheet fails to get unprotected with the same password Hans Rattink Excel Programming 3 July 28th 03 02:30 PM


All times are GMT +1. The time now is 02:21 AM.

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"