OFF98: Displaying UserForm Designer Resets Global Variables

Last reviewed: March 17, 1998
Article ID: Q182594
The information in this article applies to:
  • Microsoft Office 98 Macintosh Edition
  • Microsoft Excel 98 Macintosh Edition
  • Microsoft Word 98 Macintosh Edition
  • Microsoft PowerPoint 98 Macintosh Edition

SYMPTOMS

When you run a macro in a Visual Basic for Applications project, the value for a global variable is reset to nothing (zero).

CAUSE

This problem occurs when the following conditions are true:

  • The project includes a UserForm.

        -and-
    
  • The UserForm designer is open (the UserForm is in a window).

WORKAROUND

To resolve this problem and ensure that all global variables retain their scope, close all UserForm windows before running a macro in a Visual Basic project.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article.

MORE INFORMATION

The scope of a variable is determined by the way you declare the variable. In Visual Basic for Applications, you can use three kinds of variables: procedure, module, and public. To declare a global variable, use the Public, Dim, or Private keyword in the Declaration section of the module or procedure.

For additional information about the scope and lifetime of variables in Visual Basic for Applications, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q141693
   TITLE     : VBA: Scope of Variables in Visual Basic for Applications

REFERENCES

For more information about Scope of a variable, click the Office Assistant, type "Scope", click Search, and then click to view "Understanding Scope and Visibility."

NOTE: If the Assistant is hidden, click the Office Assistant button on the Standard toolbar. If Microsoft Help is not installed on your computer, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q179216
   TITLE     : OFF98: How to Use the Microsoft Office Installer Program


Additional query words: OFF98
Keywords : kbprg kbdta
Version : MACINTOSH:98
Platform : MACINTOSH
Issue type : kbbug
Solution Type : kbpending


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: March 17, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.