XL: Public/Global Variables Not Maintained After Error

Last reviewed: February 4, 1998
Article ID: Q155457
The information in this article applies to:
  • Microsoft Excel 97 for Windows
  • Microsoft Excel 98 Macintosh Edition

SYMPTOMS

When you run a Microsoft Excel Visual Basic for Applications macro that contains a public variable, the public variable is re-initialized if an error condition halts the execution of the macro. This is different behavior from earlier versions of Microsoft Excel and Visual Basic for Applications.

CAUSE

The mode that stops the code execution, but keeps the stack variables, was removed.

STATUS

This is by design of Microsoft Excel 97 for Windows and Microsoft Excel 98 Macintosh Edition.

MORE INFORMATION

In earlier versions of Microsoft Excel and Visual Basic for Applications, there is a mode in the internal code that stops the code execution but keeps the stack variables. This is by design of Visual Basic for Applications.

In Microsoft Excel 97 and Excel 98, this mode was removed from the internal code to make it consistent with all other Visual Basic for Applications programs. When Visual Basic for Applications encounters an error that halts a macro, it resets the project stack, including all public variables.

REFERENCES

For more information about Public Variables, click the Index tab or button in Microsoft Excel Help, type the following text

   variables, declaring

and then double-click the selected text to go to the "Public Statement" topic.


Additional query words: vbe XL97 XL98 vba
Keywords : kbprg
Version : WINDOWS:97; MACINTOSH:98
Platform : MACINTOSH WINDOWS
Issue type : kbref


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 4, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.