Check out and contribute to CodePedia, the wiki for developers.

VB.NET

Moderators: seancampbell
Number of threads: 3618
Number of posts: 9200

This Forum Only
Post New Thread

Report
Converting VBA to VB.NET Posted by VikingSpirit on 5 Nov 2009 at 3:14 PM
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.
Report
Re: Converting VBA to VB.NET Posted by seancampbell on 11 Nov 2009 at 7:55 AM
I do not know anything about command bars... I couldn't find the namespace Microsoft.VisualStudio.CommandBars. I couldn't find anything on google in the few searches I tryed

If you can provide any examples of good CommandBar code in Vb.Net then I can assist you. Otherwise, you could try finding a new method to do what you want to do.

What was the function of the command bar in your old VBA program?

Sean Campbell



 
Popular resources and forums for programmers on Programmersheaven.com
Assembly, Basic, C, C#, C++, Delphi, Java, JavaScript, Pascal, Perl, PHP, Python, Ruby, Visual Basic
© Copyright 2009 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Publisher: Lars Hagelin. Read the latest words from the publisher here.
Be the first to sign up for Lars Hagelin’s In-depth Outsourcing Newsletter here.
bootstrapLabs Logo A bootstrapLabs project.