How to Prevent Debug on Macro Error????


Posted by robert on September 13, 2001 6:34 AM

I have a password protected worksheet that has macro buttons that allow the appropriate user to unprotect the sheet and do various other tasks. However, if someone else (other than the intended user) clicks on the macro buttons while the sheet is protected or inputs the incorrect password, the macros incur a "run time error 104 Unable to set hidden property range of class." The problem is that if the unintendded user simply clicks on the END button there's no problem, but if they click on the DEBUG button, the VB editor automatically opens and anyone can see what the password in the macro and gain access. Is there anyway to prevent this? I would like to keep the hardcode pw in the macro rather than having individuals continually protect the sheet by rekeying the pw. Any help would be greatly appreciated

Posted by Barrie Davidson on September 13, 2001 6:53 AM

Robert, use the ON ERROR command. What I typically do is put this at the beginning of my code.

On Error GoTo error_Handler

Then I add this at the bottom of my code (just before END SUB.

Exit Sub
error_Handler:
MsgBox ("Error encountered, please contact programmer")
Exit Sub


Regards,
BarrieBarrie Davidson



Posted by robert on September 13, 2001 7:06 AM

Thanks!!!!

Thanks!