Macro references

J

Jennifer L

Hello,
Since I am unable to build a filter using [Current Date] as a value and I do
not want to create a custom date field with a formula, I'm thinking of just
creating a macro to do what I want.

I want the macro to filter for a specific date range. When the user runs the
macro it should filter for tasks that "start or finish after [Current Date]",
"and before [Current Date] + 14" (I'm looking for a two week range).

Can anyone recommend good VBA references to help me build this (I'm a
novice)? Or can anyone recommend a better way to do this?

My users want a way to easily toggle between viewing a two week range and
the full project schedule. I was thinking of making the macro mentioned
above, and also a -- FilterApply Name:="All Tasks" -- macro, assigning each
to a button on a toolbar so my users can click between those two buttons
without having to enter in the same date range manually.

Any help and suggestions are appreciated. Thank you!
Jennifer
 
J

Jack Dahlgren MVP

Something like this should work. I've used project statusdate instead of
current date, but you could do either one. The easiest way to do this is
turn on the macro recorder and create the filter, then insert the parameters
in the code that is generated. Here I just replaced the "Value" with the
status date.

Sub TwoWeekLookAhead()
FilterEdit Name:="2 week lookahead", _
TaskFilter:=True, _
Create:=True, _
OverwriteExisting:=True, _
FieldName:="Finish", _
Test:="is greater than or equal to", _
Value:=ActiveProject.StatusDate, _
ShowInMenu:=True, _
ShowSummaryTasks:=True

FilterEdit Name:="2 week lookahead", _
TaskFilter:=True, _
FieldName:="", _
NewFieldName:="Start", _
Test:="is less than or equal to", _
Value:=(ActiveProject.StatusDate + 7), _
Operation:="And",
ShowSummaryTasks:=True

FilterApply Name:="2 week lookahead"
End Sub
 
R

Robert

Hello Jack,

Your VBA procedure works fine on an English version of MS Project.
Do you have any idea to adapt it so that it will work on any localized
version ?

For example :
FieldName:="Finish", _
Test:="is greater than or equal to", _
....will be tanslated in French by:
FieldName:="Fin", _
Test:="Supérieur ou égal à", _

Thanks for any idea,

Gérard Ducouret

Jack Dahlgren MVP said:
Something like this should work. I've used project statusdate instead of
current date, but you could do either one. The easiest way to do this is
turn on the macro recorder and create the filter, then insert the
parameters in the code that is generated. Here I just replaced the "Value"
with the status date.

Sub TwoWeekLookAhead()
FilterEdit Name:="2 week lookahead", _
TaskFilter:=True, _
Create:=True, _
OverwriteExisting:=True, _
FieldName:="Finish", _
Test:="is greater than or equal to", _
Value:=ActiveProject.StatusDate, _
ShowInMenu:=True, _
ShowSummaryTasks:=True

FilterEdit Name:="2 week lookahead", _
TaskFilter:=True, _
FieldName:="", _
NewFieldName:="Start", _
Test:="is less than or equal to", _
Value:=(ActiveProject.StatusDate + 7), _
Operation:="And",
ShowSummaryTasks:=True

FilterApply Name:="2 week lookahead"
End Sub

Jennifer L said:
Hello,
Since I am unable to build a filter using [Current Date] as a value and I
do
not want to create a custom date field with a formula, I'm thinking of
just
creating a macro to do what I want.

I want the macro to filter for a specific date range. When the user runs
the
macro it should filter for tasks that "start or finish after [Current
Date]",
"and before [Current Date] + 14" (I'm looking for a two week range).

Can anyone recommend good VBA references to help me build this (I'm a
novice)? Or can anyone recommend a better way to do this?

My users want a way to easily toggle between viewing a two week range and
the full project schedule. I was thinking of making the macro mentioned
above, and also a -- FilterApply Name:="All Tasks" -- macro, assigning
each
to a button on a toolbar so my users can click between those two buttons
without having to enter in the same date range manually.

Any help and suggestions are appreciated. Thank you!
Jennifer
 
J

Jan De Messemaeker

Hi Gerard,

You know I have this problem in threefold.. in Belgium I encounter English,
Dutch and French version.
That is why I always use an alternative.
I make one filter, always the same, "Flag1Filter" reading Flag 1 equals Yes.
You can AFAIK copy that one through the organizer into other versions.
Then I set Flag1 for each task through VBA (which is English only!) and end
by Filterapply "Flag1Filter"
That seems to solve the multilanguage problem.

HTH
--
Jan De Messemaeker
Microsoft Project Most Valuable Professional
+32 495 300 620
For availability check:
http://users.online.be/prom-ade/Calendar.pdf
Robert said:
Hello Jack,

Your VBA procedure works fine on an English version of MS Project.
Do you have any idea to adapt it so that it will work on any localized
version ?

For example :
FieldName:="Finish", _
Test:="is greater than or equal to", _
...will be tanslated in French by:
FieldName:="Fin", _
Test:="Supérieur ou égal à", _

Thanks for any idea,

Gérard Ducouret

Jack Dahlgren MVP said:
Something like this should work. I've used project statusdate instead of
current date, but you could do either one. The easiest way to do this is
turn on the macro recorder and create the filter, then insert the
parameters in the code that is generated. Here I just replaced the
"Value" with the status date.

Sub TwoWeekLookAhead()
FilterEdit Name:="2 week lookahead", _
TaskFilter:=True, _
Create:=True, _
OverwriteExisting:=True, _
FieldName:="Finish", _
Test:="is greater than or equal to", _
Value:=ActiveProject.StatusDate, _
ShowInMenu:=True, _
ShowSummaryTasks:=True

FilterEdit Name:="2 week lookahead", _
TaskFilter:=True, _
FieldName:="", _
NewFieldName:="Start", _
Test:="is less than or equal to", _
Value:=(ActiveProject.StatusDate + 7), _
Operation:="And",
ShowSummaryTasks:=True

FilterApply Name:="2 week lookahead"
End Sub

Jennifer L said:
Hello,
Since I am unable to build a filter using [Current Date] as a value and
I do
not want to create a custom date field with a formula, I'm thinking of
just
creating a macro to do what I want.

I want the macro to filter for a specific date range. When the user runs
the
macro it should filter for tasks that "start or finish after [Current
Date]",
"and before [Current Date] + 14" (I'm looking for a two week range).

Can anyone recommend good VBA references to help me build this (I'm a
novice)? Or can anyone recommend a better way to do this?

My users want a way to easily toggle between viewing a two week range
and
the full project schedule. I was thinking of making the macro mentioned
above, and also a -- FilterApply Name:="All Tasks" -- macro, assigning
each
to a button on a toolbar so my users can click between those two buttons
without having to enter in the same date range manually.

Any help and suggestions are appreciated. Thank you!
Jennifer
 
G

Gérard Ducouret

Hi Jan,

Good idea, I'll work on that!

Gérard


Jan De Messemaeker said:
Hi Gerard,

You know I have this problem in threefold.. in Belgium I encounter
English, Dutch and French version.
That is why I always use an alternative.
I make one filter, always the same, "Flag1Filter" reading Flag 1 equals
Yes. You can AFAIK copy that one through the organizer into other
versions.
Then I set Flag1 for each task through VBA (which is English only!) and
end by Filterapply "Flag1Filter"
That seems to solve the multilanguage problem.

HTH
--
Jan De Messemaeker
Microsoft Project Most Valuable Professional
+32 495 300 620
For availability check:
http://users.online.be/prom-ade/Calendar.pdf
Robert said:
Hello Jack,

Your VBA procedure works fine on an English version of MS Project.
Do you have any idea to adapt it so that it will work on any localized
version ?

For example :
FieldName:="Finish", _
Test:="is greater than or equal to", _
...will be tanslated in French by:
FieldName:="Fin", _
Test:="Supérieur ou égal à", _

Thanks for any idea,

Gérard Ducouret

Jack Dahlgren MVP said:
Something like this should work. I've used project statusdate instead of
current date, but you could do either one. The easiest way to do this is
turn on the macro recorder and create the filter, then insert the
parameters in the code that is generated. Here I just replaced the
"Value" with the status date.

Sub TwoWeekLookAhead()
FilterEdit Name:="2 week lookahead", _
TaskFilter:=True, _
Create:=True, _
OverwriteExisting:=True, _
FieldName:="Finish", _
Test:="is greater than or equal to", _
Value:=ActiveProject.StatusDate, _
ShowInMenu:=True, _
ShowSummaryTasks:=True

FilterEdit Name:="2 week lookahead", _
TaskFilter:=True, _
FieldName:="", _
NewFieldName:="Start", _
Test:="is less than or equal to", _
Value:=(ActiveProject.StatusDate + 7), _
Operation:="And",
ShowSummaryTasks:=True

FilterApply Name:="2 week lookahead"
End Sub

Hello,
Since I am unable to build a filter using [Current Date] as a value and
I do
not want to create a custom date field with a formula, I'm thinking of
just
creating a macro to do what I want.

I want the macro to filter for a specific date range. When the user
runs the
macro it should filter for tasks that "start or finish after [Current
Date]",
"and before [Current Date] + 14" (I'm looking for a two week range).

Can anyone recommend good VBA references to help me build this (I'm a
novice)? Or can anyone recommend a better way to do this?

My users want a way to easily toggle between viewing a two week range
and
the full project schedule. I was thinking of making the macro mentioned
above, and also a -- FilterApply Name:="All Tasks" -- macro, assigning
each
to a button on a toolbar so my users can click between those two
buttons
without having to enter in the same date range manually.

Any help and suggestions are appreciated. Thank you!
Jennifer
 
J

Jennifer L

This is great! Thank you!
-Jennifer

Jack Dahlgren MVP said:
Something like this should work. I've used project statusdate instead of
current date, but you could do either one. The easiest way to do this is
turn on the macro recorder and create the filter, then insert the parameters
in the code that is generated. Here I just replaced the "Value" with the
status date.

Sub TwoWeekLookAhead()
FilterEdit Name:="2 week lookahead", _
TaskFilter:=True, _
Create:=True, _
OverwriteExisting:=True, _
FieldName:="Finish", _
Test:="is greater than or equal to", _
Value:=ActiveProject.StatusDate, _
ShowInMenu:=True, _
ShowSummaryTasks:=True

FilterEdit Name:="2 week lookahead", _
TaskFilter:=True, _
FieldName:="", _
NewFieldName:="Start", _
Test:="is less than or equal to", _
Value:=(ActiveProject.StatusDate + 7), _
Operation:="And",
ShowSummaryTasks:=True

FilterApply Name:="2 week lookahead"
End Sub

Jennifer L said:
Hello,
Since I am unable to build a filter using [Current Date] as a value and I
do
not want to create a custom date field with a formula, I'm thinking of
just
creating a macro to do what I want.

I want the macro to filter for a specific date range. When the user runs
the
macro it should filter for tasks that "start or finish after [Current
Date]",
"and before [Current Date] + 14" (I'm looking for a two week range).

Can anyone recommend good VBA references to help me build this (I'm a
novice)? Or can anyone recommend a better way to do this?

My users want a way to easily toggle between viewing a two week range and
the full project schedule. I was thinking of making the macro mentioned
above, and also a -- FilterApply Name:="All Tasks" -- macro, assigning
each
to a button on a toolbar so my users can click between those two buttons
without having to enter in the same date range manually.

Any help and suggestions are appreciated. Thank you!
Jennifer
 

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