Microsoft KB Archive/113772

= PRJ: FilterApply Method Fails with Two Interactive Dialog Boxes =

Article ID: 113772

Article Last Modified on 1/18/2007

-

APPLIES TO


 * Microsoft Project 98 Standard Edition
 * Microsoft Project 4.1 Standard Edition
 * Microsoft Project 4.1a
 * Microsoft Project 4.0 Standard Edition
 * Microsoft Project 4.0 for Macintosh

-



This article was previously published under Q113772



SYMPTOMS
In Microsoft Project, when you use the FilterApply method in a macro to apply a filter that displays multiple interactive dialog boxes, tasks that meet the criteria are not displayed.



CAUSE
The syntax for the FilterApply method is as follows:

FilterApply name, highlight, value1, value2

The value1 and value2 arguments of the FilterApply method are string expressions that specify the first and second value to use when you apply an interactive filter. However, these arguments represent values in the same interactive filter dialog box in an interactive filter that displays only two fields. These arguments do not work as the first and second values for a filter that displays two different interactive dialog boxes. You cannot specify values for more than one interactive dialog box using the FilterApply method in a macro.

For example, when you apply the Date Range filter, one dialog appears asking for the Start or Finish After criteria, and a second dialog appears asking for the Before criteria. You cannot use the value1 argument of the FilterApply method for the After criteria, and the value2 argument for the Before criteria.



WORKAROUND
To apply a filter that uses multiple interactive dialog boxes, and to supply the criteria using a macro, use either of the following workarounds.

To apply the filter and display the interactive dialog boxes
Use a SendKeys statement to enter the criteria values, as in the following example: Sub Apply_Filter1 ' Send the criteria dates and ENTER keys ' to use with the Date Range filter SendKeys "11/1{ENTER}12/1{ENTER}" ' Apply the Date Range filter FilterApply Name:="Date Range..." End Sub

To apply the filter without displaying dialog boxes
If you want to apply a filter without displaying the dialog boxes, use the FilterEdit method to create a new filter or customize an existing filter. Then, use the FilterApply method to apply this new or customized filter.

Microsoft provides examples of Visual Basic procedures for illustration only, without warranty either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. This Visual Basic procedure is provided 'as is' and Microsoft does not guarantee that it can be used in all situations. Microsoft does not support modifications of this procedure to suit customer requirements for a particular purpose.



Steps to Reproduce Behavior
 In a new project, enter a task T1. In the Start column for T1, type 11/15 . From the Tools menu, choose Macros. Choose the New button. In the Macro Name box, type Apply_Filter. Choose the Options button, and under Store Macro In, select the Current Project File option and choose OK.  In the new module, enter the following macro: Sub Apply_Filter FilterApply Name:="Date Range...", Value1:="11/1", Value2:="12/1" End Sub  From the View menu, choose Gantt Chart. From the Tools menu, choose Macros. From the Macro Name list, select Apply_Filter and choose Run.</ol>

T1 is not displayed in the project, even though T1 meets the filter criteria applied by the macro.

<div class="references_section">