title: Automatically re-initialize VBA global variables after a run-time error
body: <p>Question #1: Does <code>Public myGobalVar As Integer</code> need to be re-defined when a run-time error occurs?</p>
  
  <p>Question #2: How do I automatically re-initialize my gobal variables whenever a run-time error occurs in the code?</p>
  
  <p>Question #3: Would this error handling routine fail when dealing with unforeseen scenarios? How do I make it more fool-proof or robust?</p>
  
  <p>Please refer to the pseudo code below.</p>
  
  <pre><code>''' Question #1: Does Public myGobalVar As Integer need to be re-defined when a run-time error occurs?
  Public myGobalVar As Integer
  
  Sub Application_Startup()
      Call InitializeGobalVar()
  End Sub
  
  Sub InitializeGobalVar()
      myGobalVar = 3
  End Sub
  
  Sub One_in_many_mySubs()
  On Error Goto ErrHandler_myGobalVar
      Dim objApp as Outlook.Application
      Set objApp as Application
  
      msgbox myGlobalVar
  
      ' erroneous event may occur somewhere in the code
  
      Err.Clear
      ' skip ErrHandler_myGobalVar and exit sub after set objApp = Nothing
  
  ErrHandler_myGobalVar:
      if Err.number &lt;&gt; 0 then
  
      ''' Question #2: How do I automatically restart InitializeGobalVar whenever a run-time error occurs in the code?
          Call InitializeGobalVar
  
          MsgBox Err.Description
      end if
  
      Set objApp = Nothing
  End Sub
  </code></pre>