Menu problem in 2007

M

meg99

In a previous post (on Project.VBA), I posted a problem with running a
menu in 2007. Rod Gill answered that 2007 had disabled the .onaction
command for security reasons. When I asked how to run the macro, he
stated:

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 - 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 ""DoTrade"""


'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 =
"DoTrade"
Exit For
End If
Next


End Sub


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


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


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


Thanks,


Glen
 
R

Rod Gill

Hi,

Comments in line below:

--

Rod Gill
Microsoft MVP for Project

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



meg99 said:
In a previous post (on Project.VBA), I posted a problem with running a
menu in 2007. Rod Gill answered that 2007 had disabled the .onaction
command for security reasons. When I asked how to run the macro, he
stated:

You either need to create it manually or have the toolbar distributed
in a


Questions -

1 - 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:
Microsoft have decided teh ability to have code create a macro button on teh
fly is too dangerous so they have made it as hard as possible.

Set MyButton=CommandBars("Menu
Bar").Controls.Add(Type:=msoControlButton, _
ID:=40001, before:=16, Parameter:="Macro ""DoTrade""")
MyButton.Caption="My Caption"

might work, but no guarantees! You just have to keep trying.

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 ""DoTrade"""


'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 =
"DoTrade"
Exit For
End If
Next


End Sub


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

Distribute the Toolbar by opening a .mpp file and having a macro to use teh
OrganizerMoveItem command to copy it across. Record a macro using teh
Organizer to see the code.
3 - create an add-in. - I don't know how to do this. I looked in
his book and can't find a reference.
Add-ins are created by using Visual Studio Office. How to do this is not in
my book, but will be in teh next version coming out with the next vewrsion
of Project.
 
M

meg99

Hi,

Comments in line below:

--

Rod Gill
Microsoft MVP for Project

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









Microsoft have decided teh ability to have code create a macro button on teh
fly is too dangerous so they have made it as hard as possible.

    Set MyButton=CommandBars("Menu
Bar").Controls.Add(Type:=msoControlButton, _
             ID:=40001, before:=16, Parameter:="Macro""DoTrade""")
    MyButton.Caption="My Caption"

might work, but no guarantees! You just have to keep trying.

Thanks Rod,
That does NOT work. I get the same effect as before. Although the
caption should change, it does not.

In the Customize window there is a button titled "Modify Selection".
The dropdown window shows "Default Style" is checked.
When I select "Text Only (Always)", the caption appears. Problem is,
I must do this manually. When I try to record this action, I get
nothing.

Do you know how to set this parameter? If there is a way to set this
programmatically or in a global "Options" setup, it would solve the
problem.

Thanks,
Glen
 
R

Rod Gill

Not in 2007. Microsoft nobled this functionality. If it works in 2003 but
not in 2007 you are out of luck!

--

Rod Gill
Microsoft MVP for Project

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



Hi,

Comments in line below:

--

Rod Gill
Microsoft MVP for Project

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









Microsoft have decided teh ability to have code create a macro button on
teh
fly is too dangerous so they have made it as hard as possible.

Set MyButton=CommandBars("Menu
Bar").Controls.Add(Type:=msoControlButton, _
ID:=40001, before:=16, Parameter:="Macro ""DoTrade""")
MyButton.Caption="My Caption"

might work, but no guarantees! You just have to keep trying.

Thanks Rod,
That does NOT work. I get the same effect as before. Although the
caption should change, it does not.

In the Customize window there is a button titled "Modify Selection".
The dropdown window shows "Default Style" is checked.
When I select "Text Only (Always)", the caption appears. Problem is,
I must do this manually. When I try to record this action, I get
nothing.

Do you know how to set this parameter? If there is a way to set this
programmatically or in a global "Options" setup, it would solve the
problem.

Thanks,
Glen
 
M

meg99

Not in 2007. Microsoft nobled this functionality. If it works in 2003 but
not in 2007 you are out of luck!

--

Rod Gill
Microsoft MVP for Project

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










Thanks Rod,
That does NOT work.  I get the same effect as before.  Although the
caption should change, it does not.

In the Customize window there is a button titled "Modify Selection".
The dropdown window shows "Default Style" is checked.
When I select "Text Only (Always)", the caption appears.  Problem is,
I must do this manually.  When I try to record this action, I get
nothing.

Do you know how to set this parameter?  If there is a way to set this
programmatically or in a global "Options" setup, it would solve the
problem.

Thanks,
Glen- Hide quoted text -

- Show quoted text -

Rod,
you mentioned an update to your book will come out when the next
verion of Project is rolled out. any idea when that will be?
i have your original book and would like the update.


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