Simple Error handling in Excel VBA -
i need simple error handling code small macro, have search web have nothing simple, seems complicated.
i down load sales reports in .txt form on weekly basis, run separate macro stuff , add master page. not every week sales reports download there may not have been sales particular region.
i need simple error handler if not find report, moves next sub.
any appreciated
sub mxm_pos() workbooks.opentext filename:="c:\users\903270\documents\excel\mxmpos*.txt" ‘run macro code run ("dlk_pos") end sub
here simple basic structure can expand on needed:
sub mxm_pos() on error goto errhandler ' code here exitsub: ' shutdown code here exit sub errhandler: if err.number <> 0 dim mbr vbmsgboxresult mbr = msgbox( _ "error #" & err.number & ": " & err.description & vbnewline & _ "would continue?", vbexclamation or vbyesno) if mbr = vbyes resume exitsub application.quit end if end sub
when desire stack dump construct within source property of err object using concatenation newline, , display msgbox result @ top of calling stack, either event handler launched code or top-level macro invoked user.
Comments
Post a Comment