macro not running from menu

G

glen.e.mettler

using 2007. I have created a couple of macros. One creates a menu
title "Utilities" that contains 2 options of utilities I want to run.
I have placed this menu macro along with the utilities macros into the
global file. When I open a project the menu is there with the options
but the options do not run. I can go into the editor and run them and
they work fine but not from the menu. Part of the menu macro is:

MyMenu.Caption = "Utilities"
Set MyButton = MyMenu.Controls.Add( _
Type:=msoControlButton, ID:=1, Before:=1)
With MyButton
.OnAction = "Format_Duraation"
.Style = msoButtonCaption
.Caption = "Format Duration"
End With
Set MyButton = MyMenu.Controls.Add( _
Type:=msoControlButton, ID:=1, Before:=2)
With MyButton
.OnAction = "Rollup_Formatting"
.Style = msoButtonCaption
.Caption = "Rollup Formatting"
End With

the Format_Duration and Rollup_Formatting came with the product. The
only thing I want to do is attach them to a utility menu for
convience. The menu macro works just fine, but I can't get it to run
the macros (and I don't know how to do a "step' to debug it.

Anybody know what I have done wrong?

Glen
 
R

Rod Gill

Hi,

The vba group should soon be closing so please use the project.programming
group from now on.

To answer your question, the onaction property has been disabled in 2007 for
security reasons.

--

Rod Gill
Microsoft MVP for Project

Author of the only book on Project VBA, see:
http://www.projectvbabook.com
 
M

meg99

Hi,

The vba group should soon be closing so please use the project.programming
group from now on.

To answer your question, the onaction property has been disabled in 2007 for
security reasons.

--

Rod Gill
Microsoft MVP for Project

Author of the only book on Project VBA, see:http://www.projectvbabook.com










- Show quoted text -

Thanks Rod for the info. How can I run my user menu?

Glen
 
R

Rod Gill

You either need to create it manually or have the toolbar distributed in a
..mpp then copy across to the local Global.mpt file or create an add-in.

--

Rod Gill
Microsoft MVP for Project

Author of the only book on Project VBA, see:
http://www.projectvbabook.com



Hi,

The vba group should soon be closing so please use the project.programming
group from now on.

To answer your question, the onaction property has been disabled in 2007
for
security reasons.

--

Rod Gill
Microsoft MVP for Project

Author of the only book on Project VBA, see:http://www.projectvbabook.com










- Show quoted text -

Thanks Rod for the info. How can I run my user menu?

Glen
 
M

meg99

Rod Gill said:
You either need to create it manually or have the toolbar distributed in a
.mpp then copy across to the local Global.mpt file or create an add-in.


Questions -
1 - I cannot find Project.Programming
The address I use now is: http://groups.google.com/group/microsoft.public.project.vba/
but when I substitute .programming for .vba, I get a message that says
it can't be found.

2 - Create it manually. I did that and then wrote a macro to do it.
However, the caption is blank. So, I added code to add the caption
but that didn't work. here is the code:

Sub Macro3()
' Macro Macro3
' Macro Recorded 2/22/09 by mettlerg.
'myversion = Application.Version
mycount = CommandBars("Menu Bar").Controls.Count
mypos = mycount + 1
For b = 1 To mycount
mybar = CommandBars("Menu Bar").Controls(b).Caption
If mybar = "DoTrace" Then
CommandBars("Menu Bar").Controls(b).Delete
Exit For
End If
Next

' this creates the menu item but does not show the caption!!!
CommandBars("Menu Bar").Controls.Add Type:=msoControlButton,
ID:=40001, before:=16, Parameter:="Macro ""DoTrace"""

'The following code cycles thru the collection and finds the empty
caption and sets it - problem is, it does not work. However, when I
select Tools, Customize, Toolbars and then select the blank menu and
then select Modify Selection and then check Text Only (Always), the
caption shows. However, when I try to record those actions, I get
nothing.


mycount = CommandBars("Menu Bar").Controls.Count
For b = 1 To mycount
mybar = CommandBars("Menu Bar").Controls(b).Caption
If mybar = "" Then
CommandBars("Menu Bar").Controls.Item(b).Caption =
"DoTrace"
Exit For
End If
Next

End Sub


3 - have the toolbar distributed in a .mpp then copy across to the
local Global.mpt - I don't know what this means

4 - create an add-in. - I don't know how to do this. I looked in
your book and can't find a reference.

I am relatively new to VBA, so there may be things that are intuitive
to you but not to me

Thanks,

Glen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top