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