excel - Prevent the macro break for pass-protected self-destructing file -


i've decided create pass-protected file self-destruct after 3 wrong password entries. macro runs file open (userform pass entry field pops up) weak point ctrl-break allows stop macro , access code.

is there way disable/prevent break option in particular workbook (via vba, preferably)?

if interested, can provide macro upon request.

upd: here's macro i'm using (date based).

private sub workbook_open()     if date > cdate("30/03/2015")         warning.show     end if end sub 

this part of code assigned "ok" , "cancel" buttons of userform "warning".

public integer public b integer  sub setib()     = 2 - b     b = b + 0 end sub  private sub cnclbtn_click()     warning.hide     thisworkbook         .saved = true         .close false     end end sub  private sub okbtn_click()     call setib      dim pass string: pass = "*your pass*"     dim passinput string: passinput = warning.passfield.text      if passinput = pass         msgbox "password correct"         goto safe:     else         if b < 2             msgbox "password incorrect. " & & " attempts left."         else             msgbox "no more attempts"         end if         if b = 2             warning.hide             goto destroy:         else             warning.passfield.value = vbnullstring             warning.passfield.setfocus             b = b + 1             goto endsub:         end if     end if  safe:     activeworkbook.vbproject.vbcomponents("thisworkbook").codemodule.deletelines 1, _     activeworkbook.vbproject.vbcomponents("thisworkbook").codemodule.countoflines     warning.hide goto endsub:  destroy:     thisworkbook         .saved = true         .changefileaccess xlreadonly         kill .fullname         .close false     end  endsub:     sheet1.activate  end sub 

you password-protect vba project. avoid need worry playing application-level settings enablecancelkey.

while user may able "break" cancel key, not able view code without supplying proper password vba project.

with vbaproject protected, user can "break" execution of code, user should not able enter "break mode", , excel application not interactive (so user not able access worksheets). @ point, user form frozen on screen , application unresponsive. user has 2 options can see:

  1. if know name of userform, conceivably unload userform1 immediate window in vbe. so, should pick name userform not guess. if this, able access file itself, if give uf secure name, they'll never guess correctly.
  2. otherwise, they're sol, unless ctrl+altdel, , kill excel application procdess.

note: excel passwords, whether on worksheets or vbaproject (or both) can cracked intent on doing so, , measure prevent inadvertent corruption or manipulation of data.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -