Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 923586 - Last Review: September 18, 2011 - Revision: 2.0
Visual Basic code does not run when you use the OnAction property in Project 2007
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.
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.
The following code is an example of code in which you experience the symptom in the "Symptoms" section. This code creates the following items:
- A command bar that is named "My Menu"
- A command bar button that is named "Say Hello"
When you click the
Say Hello command bar button, a message box that contains the text "Hello!" does not appear.
Public Sub TestMenu()
Dim customBar As CommandBar
Dim newButton As CommandBarButton
Set customBar = CommandBars("Menu Bar")
customBar.Reset
Set mymenu = CommandBars("Menu Bar").Controls.Add(Type:=msoControlPopup, Before:=7)
mymenu.Caption = "My Menu"
Dim command As CommandBarButton
Set command = mymenu.Controls.Add
command.Caption = "Say Hello"
command.OnAction = "msgbox ""Hello!"""
End Sub
APPLIES TO
- Microsoft Office Project Professional 2007
- Microsoft Office Project Standard 2007
- Microsoft Project Standard 2010
- Microsoft Project Professional 2010
| kbprogramming kbautomation kbprb kbtshoot kbcode kbexpertiseinter KB923586 |
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate