View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Gai Gai is offline
external usenet poster
 
Posts: 16
Default develop a macro which takes password protection on and off

Sorry for the tardy reply- Our security at work decided to no longer allow
access to user groups! I have just got back on line.

Thanks for your help. The password protect is just for the individual
worksheets. I have since found an answer (out of complete desperation) by
using ''public const as string "[password]" and then putting the password
next to each ActiveSheet.Unprotect. This is working although I'm sure there
may be quicker ways- I'm just happy it works.

Thanks for your help- I am filing this aside for when I need that- I also
password protect workbooks.


"JMB" wrote:

Password to open or password to modify?

Sub test()
Dim wkbk As Workbook
Dim x As String
Dim y As String

x = "PwordToOpen"
y = "PwordToModify"

Set wkbk = Workbooks.Open(Filename:="I:\Excel\Pword.xls", _
Password:=x, WriteResPassword:=y)


End Sub


"Gai" wrote:

I have pretty complicated processes in Excel that I need other users to carry
out on files that I have password protect on (and need password protect on).
I have developed a macro to carry out the first of those processes, but find
that instead of accepting the password as part of the macro, a dialogue box
comes up for the password. At the end of the macro when the protection is to
go back on, it does not allow for the entry of a password at all- the end
result is the password is removed from the protection after the macro has
run. I have the macro on a separate file which only limited people will have
access to, so I can automate the password and not reduce the security.
Ideally I want the macro to accept the password as part of the actual macro
and not display a dialogue box (as the next macro I need to make will need to
remove several passwords and that could be a pain) and also of course put it
back on with a password at the end.
Has anyone come across this and has a solution in editing the macro, or is
there another way to protect with password that I don't know about? I can't
give "permissions" due to the large number of people that will be editing
portions of these files.