List of Commandbars in a file

M

Marcus

I want to extract a list of commandbars (toolbars) that I have saved in a
..mpp file. I can see them in the toolbars tab of the organiser, and I can
perform operations on them with organizermoveitem etc, but I can't find them
by looking in the project's commandbars collection with vba. How can a
programmer get a list of commandbars in a .mpp file?
This is MS Project 2003 Standard Edition. Still the only one you really need.
 
R

Rod Gill

The following displays commandbars in the immediate window, but it seems to
show a number not visible under Cusatomize. Still, it's starting point!

Sub Test()
Dim cmdbar As CommandBar
For Each cmdbar In CommandBars
Debug.Print cmdbar.Name
Next
End Sub

--

Rod Gill
Microsoft MVP for Project - http://www.project-systems.co.nz

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




Marcus said:
I want to extract a list of commandbars (toolbars) that I have saved in a
.mpp file. I can see them in the toolbars tab of the organiser, and I can
perform operations on them with organizermoveitem etc, but I can't find
them
by looking in the project's commandbars collection with vba. How can a
programmer get a list of commandbars in a .mpp file?
This is MS Project 2003 Standard Edition. Still the only one you really
need.

__________ Information from ESET Smart Security, version of virus
signature database 5103 (20100510) __________

The message was checked by ESET Smart Security.

http://www.eset.com

__________ Information from ESET Smart Security, version of virus signature database 5103 (20100510) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 
M

Marcus

Rod, that was a starting point the day before yesterday, but what I'm saying
is that the commandbars from the open .mpp file are not in the commandbars
collection, only those commandbars that are in the global.mpt file. From what
I've seen so far you can get a commandbars collection of the application or
of any open project. It always returns the same collection for some reason,
and doesn't include the toolbars saved in the .mpp file. That means that
commandbars in a .mpp file aren't shown in a collection until you copy them
to the global.mpt. That's good if you know what they are all called, but I
don't, and I can't understand why the Organizer can see them but not give me
a list of them.

If you want to try this yourself, make a custom toolbar (ref page 166 in
this really good book on Project VBA that I've got, if you can get your hands
on a copy somehow) then copy it to an open file, and delete it from Global,
using the organizer. Then use code like yours below, except dim a Project
and set it to the one with the toolbar in it. Try your code with
application.commandbars and with pr.commandbars, you will get the same list
both ways. It will be good if you do that, at least you'll know I'm not
posting questions without reading stuff you've already written and trying
basic procedures first.

thanks
Marcus
 
R

Rod Gill

Ah look at that. Found a copy of that VBA book under my desk. You're right,
the project.Commandbars collection appears to be wrong: it doesn't reflect
the bars stored in the project rather than in the Global file at all.

Looks like exactly the same behavior in Project 2010 as well.

I'll report it as a bug, but as it's minor and no one has reported yet (that
I'm aware of) I doubt it will get fixed this version.

--

Rod Gill
Microsoft MVP for Project - http://www.project-systems.co.nz

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




Marcus said:
Rod, that was a starting point the day before yesterday, but what I'm
saying
is that the commandbars from the open .mpp file are not in the commandbars
collection, only those commandbars that are in the global.mpt file. From
what
I've seen so far you can get a commandbars collection of the application
or
of any open project. It always returns the same collection for some
reason,
and doesn't include the toolbars saved in the .mpp file. That means that
commandbars in a .mpp file aren't shown in a collection until you copy
them
to the global.mpt. That's good if you know what they are all called, but I
don't, and I can't understand why the Organizer can see them but not give
me
a list of them.

If you want to try this yourself, make a custom toolbar (ref page 166 in
this really good book on Project VBA that I've got, if you can get your
hands
on a copy somehow) then copy it to an open file, and delete it from
Global,
using the organizer. Then use code like yours below, except dim a Project
and set it to the one with the toolbar in it. Try your code with
application.commandbars and with pr.commandbars, you will get the same
list
both ways. It will be good if you do that, at least you'll know I'm not
posting questions without reading stuff you've already written and trying
basic procedures first.

thanks
Marcus



__________ Information from ESET Smart Security, version of virus
signature database 5103 (20100510) __________

The message was checked by ESET Smart Security.

http://www.eset.com

__________ Information from ESET Smart Security, version of virus signature database 5103 (20100510) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 
M

Marcus

Never underestimate the value of the informed advice, "It can't be done, go
to Plan B."
thanks Rod, I'm still a fan.
Marcus
 
R

Rod Gill

Happy programming!

--

Rod Gill
Microsoft MVP for Project - http://www.project-systems.co.nz

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




Marcus said:
Never underestimate the value of the informed advice, "It can't be done,
go
to Plan B."
thanks Rod, I'm still a fan.
Marcus



__________ Information from ESET Smart Security, version of virus
signature database 5106 (20100511) __________

The message was checked by ESET Smart Security.

http://www.eset.com

__________ Information from ESET Smart Security, version of virus signature database 5106 (20100511) __________

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