Master project and sub-projects

J

Jan De Messemaeker

Hi,

For each subp in activeproject.subprojects
debug.print subp.name
next

HTH
 
N

Newbie

Hi Jan,
I already tried that syntax, but I'm getting the runtime error 438:
"Property or method not managed by this object".
What's wrong?
Thanks
 
R

Rod Gill

Can you post the code causing the problem and how you have declared each
variable?
 
J

John

Newbie said:
Hi Jan,
I already tried that syntax, but I'm getting the runtime error 438:
"Property or method not managed by this object".
What's wrong?
Thanks

Newbie,
There's a little more to the syntax than Jan indicated. Try this instead.
For Each sp in ActiveProject.Subprojects
debug.print sp.SourceProject.Name
Next sp

Be aware however that this will only give the suproject name of the
first indenture of inserted projects. If suprojects are inserted in
other subprojects a different loop structure will be needed.

John
Project MVP
 
J

John

Newbie said:
Thanks a lot John!
It works fine! But what a tricky syntax!
Thanks again

Newbie,
You're welcome. Just for reference, VBA is tricky indeed, in some cases
the compiler will not require the "Name" property, it will assume it by
default. In other cases, like your example, the full syntax is the only
thing that will make it "happy".

If VBA wasn't tricky, it wouldn't be interesting.

John
Project MVP
 

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