Question on worksheet protection and breaking macros

P

Peter Bernadyne

Hello,

I actually posted these questions in another forum, but I thought i
might help to post them here, too. I am trying to do two things I nee
assistance with:

1). I am trying to incorporate a password in my macro using workshee
protection. I am familiar with the code:

ActiveSheet.Protect

but I don't know how to incorporate the password into my code t
protect and unprotect (as with Workbooks.Open and password:= ****, fo
instance). Does anyone know if this is possible to do?

and

2). Does anyone know if there is a way to automatically close
workbook (unsaved) that a macro is acting on should the user try t
break the macro in runtime (as in Ctrl+Break)?

Any advice would be much appreciated.

Thanks,

-Pet
 
F

Frank Kabel

Hi
try

with activesheet
.unprotect password:="your password"
' your code
.protect password:="your password"
end with
 
Top