Hello All,
My question relates to creating a command bar. My VBA code I know is good
and is pretty much directly as taught through Rod's book.
I would like to focus just on creating the command bar.
In VBA:
Set MyBar = CommandBars("My Macros")
Debug.Print MyBar
If MyBar Is Nothing Then
Set MyBar = CommandBars.Add(Name:="My Macros", Position:=msoBarTop,
temporary:=False)
MyBar.Protection = msoBarNoCustomize
MyBar.Visible = True
End If
In Visual Studio using VB this is where my porting comes unstuck and where
I
need to be pointed in the right direction.
MyBar = CommandBars("My Macros")
If MyBar Is Nothing Then
CommandBars.Add(Name:="My Macros",
Position:=MsoBarPosition.msoBarTop, Temporary:=False)
MyBar.Protection = MsoBarProtection.msoBarNoCustomize
MyBar.Visible = True
End If
The problem is with the use of "CommandBars". I have imported
Microsoft.VisualStudio.CommandBars. The context message I receive is:
'Reference to a non-shared member requires an object reference.'
Everything
else is good.
This has been buggin me for a couple of days. I've tried using
_CommandBars.CommandBars - nup; Application.CommandBars - nup; among other
attempts.
Any ideas, please?
Thanks
Michael A.
__________ Information from ESET Smart Security, version of virus
signature database 4574 (20091104) __________
The message was checked by ESET Smart Security.
http://www.eset.com