Project: Macro to Create Recurring Tasks
  
PSS ID Number: Q108780
Article last modified on 03-15-1995
 
3.00 3.00a | 3.00
 
WINDOWS    | MACINTOSH
 

--------------------------------------------------------------------
The information in this article applies to:
 
 - Microsoft Project for Windows, versions 3.0, 3.0a
 - Microsoft Project for Macintosh, version 3.0
--------------------------------------------------------------------
 
SUMMARY
=======
 
The following macro provides an automated method for building a series of
recurring tasks and representing them using a single summary task in a
Gantt Chart view.
 
NOTE: This functionality is built into later versions of Microsoft Project.
 
MORE INFORMATION
================
 
To schedule the recurring tasks correctly, this macro needs to use a
calendar that has the same standard working hours as the project calendar,
but no calendar exceptions (holidays, vacations, and so on).
 
To create this calendar, do the following:
 
1. From the Options menu, choose Base Calendars.
 
2. Choose the New button.
 
3. In the Name field, type "Recurring Task Calendar" (without the quotation
   marks).
 
4. Click and drag the mouse across the day titles, M-F (or  whichever
   working days are appropriate for your project),  then enter the normal
   project working hours in the shift  boxes.
 
5. Choose the OK button.
 
6. Choose the Close button.
 
After you create the new calendar, make the following changes to the
Gantt Chart palette. These changes determine the formatting of the
recurring summary task bar.
 
 - Add a bar for the recurring task with the following definition:
 
   Bar name   Show for           From              To
   ----------------------------------------------------------------
 
   Rec Task   Flag10,Rolled Up   Scheduled Start   Scheduled Finish
 
 - Choose the bar pattern or color that you prefer for the recurring task.
 
In addition to adding this bar, add Not Flag 10 to any existing bars
that already contain Rolled Up or Summary in the Show For column. In
the default Gantt palette, this needs to be added to only two bars,
Summary and Rolled Up:
 
   Bar Name      Show For
   --------------------------------------------
 
   Summary       Summary,Not Flag10
   Rolled Up     Rolled Up,Not Summary,Not Flag10
 
NOTE: The Flag10 field will be used to indicate which tasks are
recurring tasks; use a different flag field if you are currently
using Flag10 for some other purpose.
 
Next, create the macro. To create the macro, do the following:
 
1. From the Macro menu, choose Define Macros.
 
2. Choose the New button.
 
3. Name the macro Recurring Task Builder and choose the OK button.
 
4. Enter the following macro text in the Macro Definition  dialog box.
 
WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN
RISK. Microsoft provides macro examples 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 macro is provided 'as is' and Microsoft does not guarantee
that the following code can be used in all situations. Microsoft does not
support modifications of the code to suit customer requirements for a
particular purpose.
 
Macro Code
----------
 
// Turn off alerts
Alerts .Show=[No]
OptionsProjectInfo .Calendar=[Recurring Task Calendar]
OptionsCalculation .Auto=[No]
SetField .Field=[Flag10] .Value=[Yes]
 
// Create a dummy task for later use as a positioning tool
SelectCellDown
EditInsert
SetField .Field=[Text10] .Value=[Dummy Task] .Create=[Yes]
 
// Insert and schedule proper number of recurring tasks
 
//NOTE: ENTER THE NEXT TWO LINES AS ONE LINE.
 
SelectCellDown .NumCells=[Enter number of recurring task instances:]?
.Extend=[Yes]
 
SendKeys .Keys=[+{up}]
EditInsert
 
//NOTE: ENTER THE NEXT TWO LINES AS ONE LINE.
 
SetField .Field=[Duration] .Value=[Enter period between occurrences:]?
.Create=[Yes]
 
EditLinkTasks
SelectCellLeft
 
// Set constraint date on first task
SetField .Field=[Constraint Date] .Value=[Enter date of first occurrence:]?
SetField .Field=[Constraint Type] .Value=[Start No Earlier Than]
 
// Select all recurring tasks and set constraint dates
Loop CheckField .Field=[Text10] .Value=[Dummy Task] .Test=[Not Equals]
     SelectCellDown .Extend=[Yes]
Endloop
OptionsCalculateProject
SetField .Field=[Constraint Type] .Value=[Start No Earlier Than]
SetField .Field=[Rollup] .Value=[Yes]
SetField .Field=[Flag10] .Value=[Yes]
EditUnlinkTasks
 
// Set correct duration and task names, and demote
SendKeys .Keys=[+{right}+{tab}+{up}]
EditFillDown
SendKeys .Keys=[+{down}]
OutlineDemote
 
// Delete dummy task and turn calculation back on
SelectRowStart
EditDelete
OptionsCalculation .Auto=[Yes]
 
// Loop back up to the summary task and collapse the detail tasks
SelectCellUp
Loop CheckField .Field=[Summary] .Value=[Yes] .Test=[Not Equals]
     SelectCellUp
Endloop
OutlineCollapse
 
// The following line resets the project to the correct base
// calendar. If using a calendar other than Standard, substitute
// the correct calendar name for Standard.
OptionsProjectInfo .Calendar=[Standard]
 
NOTE: Text preceded by // is a comment describing what a particular macro
command does; these comments are not required for the macro to work
properly. However, you may want to include the comments so you can use them
when reviewing the macro in the future. Also, if you input an improper
value while the macro is running, the macro will stop with an error message
saying "The command could not successfully be completed."
 
Once the macro has been created, do the following to use it:
 
1. Apply a Gantt or Task Sheet view to your project.
 
2. Apply the Entry table (or another table where Name and Duration are the
   first two unlocked columns, respectively).
 
3. Enter a single task with the name of your recurring task, and the
   duration of each task occurrence. For example, if  you want to create a
   series of 4h meetings, enter "Meeting" as the task name, and a Duration
   of 4h.
 
4. With this same task selected, run the Recurring Task Builder macro by
   using the Run command in the Define Macros dialog box. The macro will
   prompt you for the number of task occurrences, the period between
   occurrences, and the start date of the first occurrence, and will then
   use this information to build the series of recurring tasks.
 
KBCategory: kbusage
KBSubcategory:
 
Additional reference words: 3.00 3.00a
=============================================================================
Copyright Microsoft Corporation 1995.
