Hello All,
I am a newbie to Visual Studio and am looking to convert my VBA scripts to an Add-In. The first thing I need to do is create the custom toolbar.
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?
Michael A.