PRJ: Toolbar Buttons Don't Work When Using DoEvents Statement

ID: Q147409

The information in this article applies to:

SYMPTOMS

When the DoEvents statement runs in a Visual Basic for Applications macro, toolbar button commands will not run. The toolbar buttons appear fully functional, but clicking a toolbar button will not run the command for that button. Menu commands, other macros, and other applications can be run normally.

CAUSE

The DoEvents statement can be used in a macro loop to enable user input to be processed while the macro waits for something specific to happen before continuing. For example, the following macro waits until the Gantt Chart view is active:

   Sub WaitUntilGanttView()
       Do
           DoEvents
       Loop Until ActiveProject.CurrentView = "Gantt Chart"
       MsgBox "The Gantt Chart view is now active."
   End Sub

If the Gantt Chart view is not active when this macro runs, the macro will stay in the DoEvents loop until the Gantt Chart view becomes active. While the DoEvents loop runs, none of the toolbar buttons will work.

STATUS

This behavior is by design.

REFERENCES

For more information about the DoEvents statement, choose the search button in Microsoft Project 4.0 Visual Basic Reference, and type the following:

   DoEvents

For additional information, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q118468
   TITLE     : Definition of DoEvents in Visual Basic for Applications

Additional query words: 4.00
Keywords          : kbcode kbprg
Version           : 4.00 4.10 | 4.00
Platform          : MACINTOSH WINDOWS
Issue type        : kbprb

Last Reviewed: November 25, 1997