vbams-project

Name a resource filter in MS Project


I'm trying to cycle through each resource name, and print out a single sheet overview of the entire project that uses that resource (so my guys have a personalized task list of what they need to be doing).

I can pull the value of the various resources assigned to the project, and control the view using:

ResourceName = ActiveProject.Resources(i).Name
ViewApplyEx Name:="&Gantt Chart", ApplyTo:=0

and I can access the filter using:

FilterApply Name:="Using Resource..."

I can't set the resource value I want.
I tried setting Value1:= "SoAndSo", but the window popup where I'd set the value doesn't close.

I get a similar problem when trying to print the window.
I can get to the print window, but can't get the button to register so the printer gets the job.


Solution

  • Here's the implementation of my comment about an outer loop (resource) and inner loop (assignments) that effectively creates a resource To Do list. Include whatever Resource/Assignment fields you need. I suggest you pull the timescale data all the way to the right before running the macro so it doesn't appear in the printout. Remove the "preview" option in the print statement when you are ready to print.

    Dim r As Resource
    Dim a As Assignment
    For Each r In ActiveProject.Resources
        r.Flag1 = True
        For Each a In r.Assignments
            a.Flag1 = True
        Next a
        FilterEdit Name:="ResAss", taskfilter:=False, create:=True, overwriteexisting:=True, FieldName:="Flag1", _
            test:="equals", Value:="yes", ShowInMenu:=False, showsummarytasks:=False
        FilterApply Name:="ResAss"
        r.Flag1 = False
        For Each a In r.Assignments
            a.Flag1 = False
        Next a
        FilePrint preview:=True
        FilterClear
    Next r
            
    End Sub