Zel Hilliar said:
Hi John,
Thanks for the reply, however I always want the filter to run on what todays
date is, so for example if I open up the project in that specific view today,
it'll show me all tasks that have finish dates on or before the 7th Dec. And
if I opened it up next Wed the 14th December and select that view, it would
automatically show me all tasks with finish dates on or before the 12th
December.. etc..
Thanks,
Zel
Zel,
Ok, I think I understand now. You would like the filter to be
automatically applied on file open, correct? There are various ways to
do that, some easy and some more advanced.
Let's start with the easy. This method won't apply the filter
automatically but it will provide a quick convenient way to apply the
filter once the file is open. You could of course just set up the filter
as I suggested and go to Project/Filtered For and apply your filter
immediately after opening the file. You could also add the filter
selection box to a toolbar (I have mine on a customized "Formatting"
toolbar along with the view selection box and the view table selection
box). You could also set up an autofilter and set a custom filter for
the Finish field. It could test for a formula based date in a spare date
field. For example the Date1 field could be customized with the formula:
ProjDateSub(now(),"2d")
A little more advanced approach will give you exactly (what I assume)
you want but it will require the use of VBA. If you want to try it, do
the following:
1. Open the file you want to have filtered
2. Go to Tools/Macros/Visual Basic Editor
3. Hit the Project Explorer icon
4. In the Explorer pane on the left look for "VBAProject (your file name)
5. Open the folder (if necessary) until you see "ThisProject (your file
name). Double click on that icon - it will open the code pane on the
right.
6. Paste the following code in the code pane:
Private Sub Project_Open(ByVal pj As MSProject.Project)
Dim TwoDaysAgo As Date
TwoDaysAgo = DateSubtract(Now, "2d")
FilterEdit Name:="ShortList", taskfilter:=True, Create:=True, _
OverwriteExisting:=True, FieldName:="finish", _
test:="is less than or equal to", Value:=TwoDaysAgo, _
ShowInMenu:=False, showsummarytasks:=False
FilterApply Name:="ShortList"
End Sub
7. Go to File/Save [your file name]. That will save the "auto-open" code
with your file.
8. Whenever anyone opens the file, the filter will be applied. Note:
depending on your macro security setting, (Tools/Macro/Security) you may
or may not get a warning message about enabling macros when the file is
opened.
Hope this helps.
John
Project MVP