Microsoft KB Archive/123028

DurationFormat Returns Macro Error If Not Specified in Minutes

PSS ID Number: Q123028 Article last modified on 12-18-1995

4.00 | 4.00

WINDOWS | MACINTOSH

= SUMMARY =

In Microsoft Project version 4.0, Visual Basic Help states that the following DurationFormat returns a duration in the specified units, and the remarks section states the following

If you specify “2w” for the duration argument, and pjDays for the units argument, the DurationFormat method returns “14d.”

This information is only partially correct. If the units are not specified in minutes, for example, if you use the following code

MsgBox DurationFormat(“2w”,pjDays)

you receive the following error message:

Run-time error '13': Type mismatch = WORKAROUNDS =

To avoid this error message, do either of the following.

Method 1: Include the DurationValue method, as in the following example:

MsgBox DurationFormat(DurationValue(&quot;2w&quot;), pjDays)

This code will allow for the duration in question to be     completely evaluated. The DurationValue method will return the number of minutes specified in the units string. The result will be that 14d is displayed in a message box. Method 2: Specify the units in minutes, as in the following example:

MsgBox DurationFormat(4800, pjDays) '4800 equals the number of minutes in a week.

The result will be that 14d is displayed in a message box. KBCategory:kbprg kbcode kbdocerr KBSubcategory:

= Additional reference words: 4.00 help error formatting vb macro =

Copyright Microsoft Corporation 1995.