Converting macros to a ms project add-in

M

Michael A.

Before I ask a specific question, is this an appropriate forum to discuss how
to create an ms project add-in through visual studio?

thanks
Michael A.
 
G

Gary Chefetz

Michael:

Great question. Yes, the developer newsgroup for project would be the one.
microsoft.public.project.developer
 
M

Michael A.

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

Rod Gill

Can you include the Dim statements as well please. VB.Net doesn't need the
Set statement, so
MyBar = CommandBars.Add(Name:="My Macros", Position:=msoBarTop,
temporary:=False) should work.

I can't remember, but you may also need to set mybar to a new commandbar
object first.

--

Rod Gill
Microsoft MVP for Project

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




Michael A. said:
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

__________ Information from ESET Smart Security, version of virus signature database 4574 (20091104) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 

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