none
ActiveProject.TaskGroups in VBA RRS feed

  • Question

  • Hi,

    does anyone has an idea how to identify groups in an active project?
    When I use ActiveProject.xxxx, xxxx = Views, ResourceTables, TaskTables, ResourceFilters, Taskfilters, ... it works great. I only get filters, views and tables of the active project. However, if I try to do the same for groups, it shows me 14 groups for tasks and 8 for ressources, nearly all of them only available in Global.mpt. ActiveProject.ResourceGroupList.Count and ActiveProject.ResourceGroups.Count give me the same number of views, despite there is only one group (No Group) in the project. Moreover, if I loop through all groups in active project, my macro does copy all groups from Global.mpt to my active project. I have also tried with ActiveProject.TaskGroups2, it is exactly the same.

    It does even happen when doing not more than the following:
    Sub MyGroups()
    For Each rg In ActiveProject.ResourceGroups
        MsgBox rg.Name
    Next rg
    End Sub

    Is there any chance to read only the existing groups in my active project? I am looking forward to any help!
    Thanks in advance,
    Barbara

    Saturday, March 19, 2011 12:17 PM
    Moderator

Answers

  • Babara,

    You didn't specify which version of Project but my guess is that this little "glitch" in VBA probably transcends all versions.

    I set up a simple test file with a single custom group. Like you experienced, the XXXGroupList Property gives the whole global set not just those of the active project. Bummer, but as you are probably well aware, it's not the first issue with Project's VBA object model. When I run across these "glitches" I look for potential work-arounds. In this case I noticed something that might be of use. If you cycle through each group in the list for the active project, the custom groups will appear first. For Project 2007 (my test bed of convenience) there are 9 default task groups and 7 default resource groups. Knowing that, you should be able to deduce the groups associated with the active project only. Although it's not the preferred or perfect solution, sometimes you just have to go with the flow and do an end-around-run.

    Hope this helps.

    John

    Monday, March 21, 2011 3:54 AM

All replies

  • Babara,

    You didn't specify which version of Project but my guess is that this little "glitch" in VBA probably transcends all versions.

    I set up a simple test file with a single custom group. Like you experienced, the XXXGroupList Property gives the whole global set not just those of the active project. Bummer, but as you are probably well aware, it's not the first issue with Project's VBA object model. When I run across these "glitches" I look for potential work-arounds. In this case I noticed something that might be of use. If you cycle through each group in the list for the active project, the custom groups will appear first. For Project 2007 (my test bed of convenience) there are 9 default task groups and 7 default resource groups. Knowing that, you should be able to deduce the groups associated with the active project only. Although it's not the preferred or perfect solution, sometimes you just have to go with the flow and do an end-around-run.

    Hope this helps.

    John

    Monday, March 21, 2011 3:54 AM
  • Hi John,

    ok, normally I am asking for version? ;-) It is the same for 2007 and 2010 and it causes my some headache. Your idea is great and works perfect! Thank you!

    Barbara

    Monday, March 21, 2011 4:33 AM
    Moderator
  • Barbara,

    You're welcome and I'm glad I could help.

    John

    Monday, March 21, 2011 3:21 PM