Lesson 4: View, Table and Filter Methods

Lesson Objectives

Upon completion of this lesson, the participant will be able to:

Some Topics to be introduced in this lesson include:

Views Methods

Project gives you full control over views by using Application Object methods. Here is a listing of the possible view methods.

ViewApply Sets the view in the active window. The same as choosing View More Views and then applying a view from the list. To set the Module Editor View use the following.

ViewApply name:="Module Editor", singlePane:=True

ViewEditCombination and ViewEditSingle Methods allows the user to create or edit a single or combination view. The benefit is that the user does not have to see any dialog box displayed.

ViewEditCombination name := "Kris' View", create := True,_ topView := "Resource Sheet",_ bottomView := "Resource Graph"

ViewEditSingle name := "Kris' Task Schedule", create := True, _ filter:="In Progress Tasks", table := "Schedule"

The ViewList method is used to return a view name or a list of all view names defined in the project. TaskViewList only returns those that are task views.

For Each t In ActiveProject.ViewList

MsgBox t

Next t

There are 15 ViewShowXXXX methods, which allows you to format the task and resourse forms. The equivalent would be going to your format menu choosing details and then picking one type from the list. The 15 types are: Availability, Cost, CumulativeCost, CumulativeWork, Notes, Objects, Overallocation, PeakUnits, PercentAllocation, PredecessorsSuccessors, ResourcesPredecessors, ResourcesSuccessors, Schedule, SelectedTasks, and Work

ViewShowSchedule

Exercise

Write a macro that creates and applies a split screen view with a Task Sheet on top and a Task Form on the bottom formated to show Resource Cost. (**Do not use the macro recorder)

Tables Methods

The Tables method is another Application Object method. It is used for setting the active pane in the active window. If you executed the Tables method it would simply bring up the More Table dialog box.

In order to give the user more control, Project supplies the TableApply method. When used, the user must supply a valid name of a table. In return, no dialog box will be displayed.

TableApply "Tracking"

If you would like to create a new or edit an existing table, you should use the TableEdit method. This method allows full customization of 15 options in a table. The following macro command will create a new table called Flags containing task information and does not appear in the menu.

TableEdit name := "Flags", taskTable := True, create := True, _

fieldName := "Priority", showInMenu := False

The TaskTableList and ResourceTableList methods are used to return a task or resource table name or a list of all task or resource tables currently defined in the project.

For Each t In ActiveProject.TaskTableList

MsgBox t

Next t

Exercise1

Using the list of customizable options for a table, listed in online help, write a macro that creates a new table containing fields: ID, Name, Actual Start, and Actual Finish. Do not use the macro recorder. (Hint: A new TableEdit line is necessary for each field you add)

Filter Methods

The Filters method is another Application Object method. It is used for setting the filter of the active pane in the active window. If you made a call to the Filters method it would simply bring up the More Filters dialog box.

In order to give the user more control, Project supplies the FilterApply method. When used, the user must supply a valid name of a filter. In return, no dialog box will be displayed.

FilterApply "Milestones"

If you would like to create a new or edit an existing Filter, you should use the FilterEdit method. This method allows full customization of 12 options in a filter. The following example creates a filter for tasks with the highest priority (if one doesn't exist), and then applies the filter.

Sub CreateAndApplyHighestPriorityFilter()

Dim TaskName ' Index for For Each loop

Dim Found ' Whether or not the filter exists.

Found = False ' Assume the filter doesn't exist.

 

For Each TaskName In ActiveProject.TaskFilterList

If TaskName = "Highest Priority" Then

Found = True

Exit For

End If

Next TaskName

 

' If filter doesn't exist, create it.

If Not Found Then FilterEdit Name:="Highest Priority", _

create:=True, taskFilter:=True,_

FieldName:="Priority", _

test:="equals", value:="Highest"

 

' Apply the filter.

FilterApply "Highest Priority"

End Sub

The TaskFilterList and ResourceFilterList methods are used to return a task or resource filter name or a list of all task or resource filters currently defined in the project.

For Each t In ActiveProject.FilterTableList

MsgBox t

Next t

Exercise1

Using the list of customizable options for a filter, listed in online help, write a macro that creates a new interactive filter that will prompt the user to enter a beginning ID and an Ending ID, then displays only milestones in that range. Do not use the macro recorder. (Hint: A new FilterEdit line is necessary for each row you add)