PRJ: FilterApply Method Fails with Two Interactive Dialog Boxes

ID: Q113772

The information in this article applies to:

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.

WORKAROUNDS

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.

MORE INFORMATION

Steps to Reproduce Behavior

1. In a new project, enter a task T1. In the Start column for T1, type

   "11/15" (without the quotation marks).

2. From the Tools menu, choose Macros. Choose the New button. In the Macro
   Name box, type "Apply_Filter" (without the quotation marks). Choose the
   Options button, and under Store Macro In, select the Current Project
   File option and choose OK.

3. In the new module, enter the following macro:

      Sub Apply_Filter
         FilterApply Name:="Date Range...", Value1:="11/1", Value2:="12/1"
      End Sub

4. From the View menu, choose Gantt Chart.

5. From the Tools menu, choose Macros. From the Macro Name list, select

   Apply_Filter and choose Run.

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

REFERENCES

For additional information, please see the following article(s) in the Microsoft Knowledge Base:

   ARTICLE-ID: Q126941
   TITLE     : Creating a Multi-Line Filter Using the FilterEdit Method

For more information about the FilterApply Method, choose the Search button in the Visual Basic reference and type:

   FilterApply

For more information about the FilterEdit Method, choose the Search button in the Visual Basic reference and type:

   FilterEdit

Additional query words: 4.00
Keywords          : kbcode kbprg
Version           : 4.0 4.1 4.1a 98
Platform          : MACINTOSH WINDOWS
Issue type        : kbprb

Last Reviewed: November 25, 1997