How to use Microsoft Project SetAutoFilter Enumerated Types like pjAutoFilterLessThan?

334 Views Asked by At

I am in the process of building a form for more quickly filtering through tasks in Microsoft Project. For example, the form populates ListBox controls with field values, which a user can use to select what they want to filter on. Another example is a checkbox for filtering out tasks that are 100% complete.

I've been having to use the custom filter (pjAutoFilterCustom) for Duration and "% Complete" fields, as I've been unsuccessful in using pjAutoFilterLessThan and pjAutoFilterGreaterThan. The following custom filter works, while the pjAutoFilterLessThan filter does not:

SetAutoFilter FieldName:="% Complete", FilterType:=pjAutoFilterCustom, Test1:="is less than", Criteria1:="100"
SetAutoFilter FieldName:="Duration", FilterType:=pjAutoFilterLessThan, Criteria1:="100"

For the second filter returns the following error:

Run-time error '1101': The argument is not valid

The entire line of code is highlighted in the Visual Basic editor, so I'm not sure what's wrong. Other non-custom enumerated types that I use, such as pjAutoFilterIn work fine.

1

There are 1 best solutions below

0
On BEST ANSWER

After asking a question here, it looks like Project has a problem with SetAutoFilter that has not been resolved, yet. So, the answer appears to be to rely on the custom-filtered auto-filters.