View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
DavidC[_2_] DavidC[_2_] is offline
external usenet poster
 
Posts: 44
Default How could I run my macros in a protected with password worksheet

The macros will still work generally when a workbook nis
protected. It is only when your try and run a command in
VBA which is not available to run when the workbook is
protected that the macro will fail. An example of this is
conditional formatting. If you protect a workbook and try
and add conditional formatting through the menu it will ot
let you. An so with VBA the commands for those same
things will not run in VBA either. If a command runs
normally off the menu when the workbook is protected then
it should run in VBA.

If you really do need to protect and unprotect on the run
then try these:

Private Sub unprotect_cells()

ActiveWorkbook.UnprotectSharing ("xxx")
ActiveSheet.Unprotect ("xxx")

End Sub

Private Sub protect_sheet()

Dim wrkbk As String

ActiveSheet.Protect ("xxxx")
wrkbk = ThisWorkbook.Name


End Sub

BOL
David C
-----Original Message-----
Hi everyone!,

I am building an small application where I want the data

in a worksheet
be protected with a password and still be capable to run

macros (Excel
2000). I been reading the messages in this forum and i

get the idea to
include the protect / Unprotect instruction in the macro
(ActiveWorkbook.Unprotect Password:="abcd"). I already

did that but it
doesn´t work (error 1004).

Could you give me a hand?

Thank you all.

Jose


---
Message posted from http://www.ExcelForum.com/

.