excel - Error 91 when unloading form after Error Handling -
hello fellow developers,
i working on little project internship in vba excel (it first time project in vba). program includes several modules , userforms, , complete, implemented error handling.
i used :
sub ....... modname = "nameofthemodule" subname = "nameofthesub/function" on error goto proc_err /code exit sub proc_err: call loggenerator(modname, subname, erl, err.number, err.description) exit sub end sub
(sorry can't post whole file, quite confidential)
i wrote code in every sub or function, along line numbers, in case there error, goes proc_err, calls loggenerator that'll generate .txt file module name, sub/function name, line number, error number. don't know if that's best way, works treat.
until now.
now, when code runs in userform code, log generated, userform doesn't close. pretty dangerous, because still "active", meaning user still put data , validate, though there error before.
i tried putting "unload me "in proc_err, (i tried putting after/before "exit sub", after/before call of loggenerator), error 91 (can't post picture, need more reputation...). however, works, , unloads userform...
i wrote sub unloadalluserform call loggenerator sub same error.
i don't have acces debugging help, there in vba editor (highlighting faulty line), managed, debug.print, find it's line "unload" raises error.
i added error handling in unloadalluserform sub, trying "on error resume next", error still shows!!!
sub unloadalluserform() on error goto proc_err modname = "errhandler" subname = "unloadall" dim frm userform each frm in userforms frm.hide next frm exit sub proc_err: call loggenerator(modname, subname, erl, err.number, err.description) exit sub end sub
i error91 when there's error in userform_initialize sub. however, error 91 in userform_initialize sub, whatever userform is. still put sample of 1 userform_initialize here :
'initialisation de l'userform private sub userform_initialize() modname = "userformajoutitem" subname = "userformajoutitem_initialize" on error goto proc_err 10 'on définit la page "ajout pièce comme la page par défaut à l'ouverture 20 multipage.value = 0 30 40 'pour chaque objet de type textbox présent dans l'userform, on initialise à valeur vide 50 dim z control 60 each z in userformajoutitem.controls 70 if typename(z) = "textbox" 80 z.value = vbnullscript 90 end if 100 next z exit sub proc_err: unload me call loggenerator(modname, subname, erl, err.number, err.description) exit sub end sub
i never had , i'm out of ideas.
your appreciated, lot!
as stated me , user3964075, can't unload in initialize event.
you have pass boolean
after initialize event gets checked in sub
if true
= unload
if false
= continue
Comments
Post a Comment