Project: Macro to Change Task Duration by Constant Amount
  
PSS ID Number: Q108459
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 and 3.0a
 - Microsoft Project for Macintosh, version 3.0
--------------------------------------------------------------------
 
SUMMARY
=======
 
The following macro provides a method to increase or decrease the duration
of all tasks in a Microsoft Project file by a given percentage.
 
MORE INFORMATION
================
 
Creating the Macro
------------------
 
To create this macro, follow the steps below.
 
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.
 
1. To use this macro, you must first create a custom table. To create this
   table, do the following:
 
   a. From the Table menu, choose the Define Tables command.
 
   b. Choose the New button.
 
   c. Name the new table "Change Duration" (without the quotation marks)
      and choose the OK button.
 
   d. Add the following fields to the table in the order shown below:
 
         ID
         Duration
         Number1
 
     The Lock First Column check box should be selected.
 
2. To create the macro, do the following:
 
   a. From the Macro menu, choose Define Macros.
 
   b. Choose the New button.
 
   c. Name the macro and choose the OK button.
 
   d. Enter the following Macro code in the Macro Definition dialog box.
 
      NOTE: Text preceded by // is a comment describing what a particular
      macro command does. Although these comments are not required for the
      macro to work properly, you may want to include them so that you can
      use them when you review the macro in the future.
 
   Macro Code
   ----------
 
   // These lines set the current view, table, and filter
   View .Name=[Task Sheet]                   // Apply Task Sheet view
   Table .Name=[Change Duration]             // Apply custom table
   Filter .Name =[All Tasks]                 // Display all tasks
 
   // All durations must be in units of Days for this macro to work.
   // The following lines convert the Duration values of all tasks
   // to units of Days.
   OptionsPreferences .DurationUnits=[2]     // Set Default Duration
                                             // units to Days
   SelectColumn                              // Select Duration column
   EditCopy                                  // Copy it
   SelectCellRight                           // Move to Number1 column
   SelectColumn                              // Select Number1 column
   EditPaste                                 // Paste duration values
   EditCopy                                  // Copy Number1 column
   SelectCellLeft                            // Move to Duration column
   SelectColumn                              // Select Duration column
   EditPaste                                 // Paste values
 
   // Alter Default Hours/Day to effect Duration change. The argument
   // for this command is equal to DHD/(1+delta), where DHD is your
   // standard value for Default Hours/Day, and delta is the
   // percentage change in duration. Positive values of delta indicate
   // a duration increase; negative values indicate a decrease. This
   // value must be entered directly in the macro code. The macro is
   // unable to prompt for this information.
 
   // In this example, the value 6.4 is used to increase duration by
   // 25% when the Default Hours/Day = 8. {6.4 = 8/(1 +.25)}
 
   OptionsPreferences .Hours/Day=[6.4]       // Set Default Hours/Day to
                                             // new value
 
   // These lines copy the new Duration values to the Number1
   // column so they will not be lost when the Default Hours/Day is
   // reset.
   SelectColumn                              // Select Duration column
   EditCopy                                  // Copy it
   SelectCellRight                           // Move to Number1 column
   EditPaste                                 // Paste Duration values
 
   // The following lines reset Default Hours/Day and copy the new
   // Duration values back from the Number1 column to the Duration
   // column.
   OptionsPreferences .Hours/Day=[8]         // Reset Default Hours/Day
   SelectColumn                              // Select Number1 column
   EditCopy                                  // Copy it
   SelectCellLeft                            // Move to Duration column
   SelectColumn                              // Select Duration column
   EditPaste                                 // Paste new values
 
Once the macro has been created, it can be executed using the Run
command in the Define Macros dialog box to alter your task duration.
 
The percentage duration change must be coded directly into the macro (see
the macro comments for details). To run the macro again using a different
percentage, edit the appropriate value in the macro first.
 
NOTE: After running the macro, all task duration will be displayed in units
of Days.
 
KBCategory: kbusage
KBSubcategory:
 
Additional reference words: 3.00 3.00a
=============================================================================
Copyright Microsoft Corporation 1995.
