Look Ahead Filter

H

HDLF

I would like to reference the "current date" or "status
date" in a custom task filter. I would like to build a
custom filter that shows on those tasks with end dates
between "current date - 28days" and "current date +
120days" without having to manually enter the dates.

Is there a way I can reference this variable in the custom
filter utility? If not, is there another way to do this?
 
J

JackD

Using some VBA you can do it.

Sub Macro1()
With ActiveProject
'create a new filter
FilterEdit Name:="Filter Lookahead", _
TaskFilter:=True, _
Create:=True, _
OverwriteExisting:=True, _
FieldName:="Finish", _
Test:="is greater than or equal to", _
'with the first condition
Value:=(Now() - 28), _
ShowSummaryTasks:=False
'now edit the filter
FilterEdit Name:="Filter Lookahead", _
TaskFilter:=True, _
FieldName:="Finish", _
NewFieldName:="Finish", _
'to add a second condition
Test:="is less than", Value:=(Now() + 120), _
'including the operation
Operation:="And", _
ShowSummaryTasks:=False
'finally apply the filter
FilterApply Name:="Filter Lookahead"
End With
End Sub
 
H

HDLF

Thanks Jack, please bear with me since I am not too
familiar with VBA. I can follow the code. I went to
macros, created a new module in the project (happens to be
a master project), and copied in your macro. When I
hit "run" I get a "compile syntax error". The first block
under "create new filter" is hightlighted in blue. Can you
please step me through the process a little?
 
H

HDLF

I got it to work. I think the problem was with the
carriage returns or the continuation character ("_" ?). I
deleted these and made one big line (which now scrolls off
the screen). It created the filter in my menu and it seems
to work.

Thank you VERY MUCH!

If I type in a "_" will it work as a continuation? I'm
running MSPro 2003?
 
J

John

HDLF,
The continuation syntax is not just an underscore, it needs to have a
space in front of it (i.e. " _").

John
 
J

JackD

a space and then underline " _" should work as a continuation character. It
worked for me before I sent it.

Oh, actually on second thought it worked before I put the comments in... Now
I realize that the comments are in the middle of the line and of course that
will break the code. Sorry.

You can put the continuation characters back in to help with readability.
I hate to have to scroll horizontally to edit code so I use them often.

-Jack
 
H

HDLF

I moved some of the things around and the macro is working
GREAT! Now the bad I copied the macro up to a master project file and it also
works on the subprojects (the first time). When I tried to
save the master file I received the "Microsoft has
encountered a problem......to you want to send a
report....." pop up window. Of course after you
click 'yes'or 'no', ALL of MS Project closes down.
Now when I open up the master file, the macro is still
there. However if I try to run the macro, I get an error
window that says: "The macros in this project are
disabled. Please refer to the online help or documentation
of the host application to determine how to enable
macros.". Of course if I close MSProject (even without
saving) I get the "Send Microsoft a report" window again.

Any thoughts? Is there a know problem with using macros
in a master project?
 
G

Guest

I've been looking for a list of field names/variables to
use in modifying this macro, but can't come up with
anything. I'd like to reference the date the project was
updated, as opposed to now() (which may of course be
several days after the project was updated). I even toyed
with putting the update date in manually using one of the
Project Properties (custom tab), though that's not the
optimal solution.

What I really want is a full list of all
objects/fields/properties/variables that I may need to
reference. I did bump into the list of date/file location
properties in help, but couldn't find a comprehensive list.
 
J

JackD

You can get most of the activeproject properties (statusdate, lastsavedate)
simply by typing activeproject. and seeing what choices the "intellisense"
gives you to complete the statement.

I think that you would probably want to use either StatusDate or
LastSaveDate for what you are doing.

There are also some builtin properties which are a bit more elusive. I don't
think that the documentation ever names them all in one place, so since I
got tired of looking I wrote some code to return a list of them. It loops
through the properties collections and returns the name and index.
See code sample below.

-Jack

-----snip--------------

Sub writemyproperties()
'This macro exports all the built-in and custom project properties
'to a text file. It lists the index of the property, the name and the value.
'It demonstrates the use of a simple error handler to skip the errors that
'occur when a property is not defined or used.

'Copyright Jack Dahlgren, Feb 2002

Dim mystring, MyFile As String
Dim fnum, myIndex As Integer
Dim myProj As Project
Dim skipme As Boolean

'set location and name of file to be written
MyFile = "c:\" & ActiveProject.Name & "_properties.txt"
skipme = False
'set and open file for output
fnum = FreeFile()
Open MyFile For Output As fnum

'write project info and then a blank line
Write #fnum, "Built In Properties"
Write #fnum,
myIndex = 1
Set myProj = ActiveProject
While myIndex <= myProj.BuiltinDocumentProperties.Count
On Error GoTo ErrorHandler
mystring = (myIndex & ") " & myProj.BuiltinDocumentProperties(myIndex).Name
& ": " & myProj.BuiltinDocumentProperties(myIndex).Value)
If Not skipme Then
Write #fnum, mystring
End If
myIndex = myIndex + 1
skipme = False
Wend
Write #fnum, "-----------------------------------------------"
Write #fnum,
Write #fnum, "Custom Properties"
Write #fnum,
myIndex = 1
While myIndex <= myProj.CustomDocumentProperties.Count
On Error GoTo ErrorHandler
If Not skipme Then
mystring = (myIndex & ") " &
myProj.CustomDocumentProperties(myIndex).Name & ": " &
myProj.CustomDocumentProperties(myIndex).Value)
Write #fnum, mystring
End If
myIndex = myIndex + 1
skipme = False
Wend
Close #fnum

ErrorHandler:
skipme = True
Resume Next

End Sub

-----snip--------------
 
T

TKS

Excellent! That's so much information than I had before.
And I'm glad to hear that it wasn't necessarily my poor
search skills that kept me from finding this info.

Regards,
 
J

JackD

You are welcome. Glad it helped.

-Jack

TKS said:
Excellent! That's so much information than I had before.
And I'm glad to hear that it wasn't necessarily my poor
search skills that kept me from finding this info.

Regards,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top