Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default Help on Macro

Good morning. A couple of weeks ago, someone from this forum, was very
helpful in my question on how to unprotect protected worksheets, with similar
passwords, with a macro. Below is a copy of the VB script I was given. It
worked but then I realized, the password "hi" is now visible under the macro
script. Is there a way to rewrite the code so that it will not show the
password and instead when the macro is run, one has to enter the password
before the macro can unprotect the protected worksheets?

thank you very much,
Storm

Option Explicit
sub testme()
dim myPWD as string
dim wks as worksheet
myPWD = "hi"
for each wks in activeworkbook.worksheets
wks.unprotect password:=mypwd
next wks
end sub

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

You could encrypt the password and then unencrypt it when you need to use it.

But easier would be to protect the workbook's project.
Inside the VBE
select your project
Tools|VBAProject Properties|Protection tab

Lock it for viewing and give it a memorable password.

Be aware that this password isn't going to stop the really dedicated--but it
will keep most people out.



Storm wrote:

Good morning. A couple of weeks ago, someone from this forum, was very
helpful in my question on how to unprotect protected worksheets, with similar
passwords, with a macro. Below is a copy of the VB script I was given. It
worked but then I realized, the password "hi" is now visible under the macro
script. Is there a way to rewrite the code so that it will not show the
password and instead when the macro is run, one has to enter the password
before the macro can unprotect the protected worksheets?

thank you very much,
Storm

Option Explicit
sub testme()
dim myPWD as string
dim wks as worksheet
myPWD = "hi"
for each wks in activeworkbook.worksheets
wks.unprotect password:=mypwd
next wks
end sub


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 417
Default Help on Macro

Use an InputBox statement to prompt the user, like so:

Sub UnlockAllWorksheets()
Dim strPassword As String
Dim ws As Worksheet

strPassword = InputBox("Enter the password for all worksheets: ", _
"Unlock Worksheets")

For Each ws In ActiveWorkbook.Worksheets
ws.Unprotect password:=strPassword
Next ws
End Sub
--
Regards,
Bill Renaud



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
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
how to count/sum by function/macro to get the number of record to do copy/paste in macro tango Excel Programming 1 October 15th 04 01:16 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


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