Microsoft KB Archive/923586

= Visual Basic code does not run when you use the OnAction property in Project 2007 =

Article ID: 923586

Article Last Modified on 11/3/2006

-

APPLIES TO


 * Microsoft Office Project Professional 2007
 * Microsoft Office Project Standard 2007

-





SYMPTOMS
You use the OnAction property to set Microsoft Visual Basic code to run when you click a command bar control in Microsoft Office Project 2007. However, when you click the command bar control, the code does not run.



CAUSE
This behavior occurs because Project 2007 does not support the OnAction property. Therefore, the code does not run when you click the command bar control in Project 2007.



MORE INFORMATION
The following code is an example of code in which you experience the symptom in the &quot;Symptoms&quot; section. This code creates the following items:
 * A command bar that is named &quot;My Menu&quot;
 * A command bar button that is named &quot;Say Hello&quot;

When you click the Say Hello command bar button, a message box that contains the text &quot;Hello!&quot; does not appear. Public Sub TestMenu Dim customBar As CommandBar Dim newButton As CommandBarButton Set customBar = CommandBars(&quot;Menu Bar&quot;) customBar.Reset

Set mymenu = CommandBars(&quot;Menu Bar&quot;).Controls.Add(Type:=msoControlPopup, Before:=7) mymenu.Caption = &quot;My Menu&quot; Dim command As CommandBarButton Set command = mymenu.Controls.Add command.Caption = &quot;Say Hello&quot; command.OnAction = &quot;msgbox &quot;&quot;Hello!&quot;&quot;&quot; End Sub

Keywords: kbprogramming kbautomation kbprb kbtshoot kbcode kbexpertiseinter KB923586

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.