Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Converting Weeks to Days

173 views
Skip to first unread message

JJ

unread,
Jan 18, 2010, 1:02:30 PM1/18/10
to
I have a Project file that some created where they planned everything
exclusively in weeks. I wanted to convert all the durations to days.
Two questions:

Question 1)
Here's the code that I wrote to do this but it's really slow. I can't
determine if it's my computer or if the code is processor-intensive.

Dim t As Task

For Each t In ActiveProject.Tasks
If Not t Is Nothing Then
If t.Summary = False Then
t.Duration = DurationFormat(t.Duration, Units:=pjDays)
End If
End If
Next

Question 2)
How do I get the durations on the Summary Tasks to display in days? I
tried the DurationFormat method above on Summary Tasks but it would
not allow it.

Thanks!
JJ

Unknown

unread,
Jan 18, 2010, 1:30:47 PM1/18/10
to
Why don't you just use the built in FormatDuration macro? That does the
same thing, no?

- Andrew Lavinsky
Blog: http://blogs.catapultsystems.com/epm

JJ

unread,
Jan 18, 2010, 2:39:00 PM1/18/10
to
I do not see a "FormatDuration" macro. I am currently using Microsoft
Project 2003. Is this a MS Project 2007 macro?

The only duration-formatting built-in function that I could find is
the one that I have in the code... DurationFormat(Duration,Units)

Unknown

unread,
Jan 18, 2010, 2:48:06 PM1/18/10
to
I am pretty sure it was in 2003. If you go to Macros, do you have any out
of the box Macros in the Global.MPT file? Project ships with 3-4 built in
ones, one of which does pretty much what you're looking for.

Here's the code for it:

'DISCLAIMER OF WARRANTY
'
'THE SAMPLES DESCRIBED IN THIS DOCUMENT ARE UNDOCUMENTED SAMPLE CODE.
'THESE SAMPLES ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND.
'MICROSOFT FURTHER DISCLAIMS ALL IMPLIED WARRANTIES INCLUDING WITHOUT
'LIMITATION ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR OF FITNESS
'FOR A PARTICULAR PURPOSE. THE ENTIRE RISK ARISING OUT OF THE USE OR
'PERFORMANCE OF THE SAMPLES REMAINS WITH YOU.
'
'IN NO EVENT SHALL MICROSOFT OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES
'WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF
'BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION,
'OR OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE
'THE SAMPLES, EVEN IF MICROSOFT HAS BEEN ADVISED OF THE POSSIBILITY OF
'SUCH DAMAGES. BECAUSE SOME STATES DO NOT ALLOW THE EXCLUSION OR
'LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE
'ABOVE LIMITATION MAY NOT APPLY TO YOU.
' This macro reformats the duration of all the tasks in the project.
' The durations are all expressed in either minutes, hours, days, or weeks.
' The macro also sets the default duration unit. All summary tasks
' and new tasks will be shown in that unit.

Option Explicit

Const MB_NOFILEOPEN = "You do not have a project open. Open a project, and
then run the macro again."

Sub Format_Duration()
Application.OpenUndoTransaction ("Format Duration")
On Error GoTo ErrorHandler

Check_if_Project_Open

frmFormatDuration.InitializeList
frmFormatDuration.cboDurUnit.SetFocus
frmFormatDuration.cboDurUnit.SelStart = 0
frmFormatDuration.cboDurUnit.SelLength = frmFormatDuration.cboDurUnit.TextLength
frmFormatDuration.Show
ExitSub:
Application.CloseUndoTransaction
Exit Sub

ErrorHandler:
ProcessError Err
GoTo ExitSub
End Sub

Private Sub Check_if_Project_Open()
'Procedure checks if a project file is open

On Error GoTo NoFileOpen:

Dim strName As String

strName = ActiveProject.Name

Exit Sub

NoFileOpen:
MsgBox MSG_NO_PROJECT_OPEN, vbExclamation + R_TO_L, Title:=Application.Name
End 'End the macro

End Sub

Jan De Messemaeker

unread,
Jan 18, 2010, 3:39:23 PM1/18/10
to
Tools, Macro, Macros
If you do not see Format duration Macro, Security, set to Low

--
Jan De Messemaeker
Microsoft Project Most Valuable Professional
+32 495 300 620
For availability check:
http://users.online.be/prom-ade/Calendar.pdf
"JJ" <metal...@gmail.com> wrote in message
news:d716749f-2fdc-42fb...@h9g2000yqa.googlegroups.com...

JJ

unread,
Jan 18, 2010, 5:29:21 PM1/18/10
to
Thanks Jan and Andrew! I was able to find it after setting the Macro
Security to low. I am running it now, but I am noticing that it takes
just as long to complete as the code I wrote. It still has not
completed; however, I am assuming that it will convert Summary Tasks
as well. In any case, it is there.

Thanks again!
JJ

On Jan 18, 12:39 pm, "Jan De Messemaeker" <janremovet...@prom-ade.be>
wrote:


> Tools, Macro, Macros
> If you do not see Format duration Macro, Security, set to Low
>
> --
> Jan De Messemaeker
> Microsoft Project Most Valuable Professional
> +32 495 300 620

> For availability check:http://users.online.be/prom-ade/Calendar.pdf"JJ" <metaldog...@gmail.com> wrote in message

JJ

unread,
Jan 18, 2010, 8:54:59 PM1/18/10
to
I just wanted to add that my IMS has 2400+ tasks and it took 38
minutes to format all the durations to days using the Format_Duration
macro.

Is this normal? Just curious.

Unknown

unread,
Jan 18, 2010, 9:45:34 PM1/18/10
to
It all depends on the specs of your computer and what else you have running.
It may be of some solace to note that Project 2010 has a 64bit version which
is designed for power users of larger schedules.

> I just wanted to add that my IMS has 2400+ tasks and it took 38


> minutes to format all the durations to days using the Format_Duration
> macro.
>
> Is this normal? Just curious.
>
> On Jan 18, 2:29 pm, JJ <metaldog...@gmail.com> wrote:
>
>> Thanks Jan and Andrew! I was able to find it after setting the Macro
>> Security to low. I am running it now, but I am noticing that it takes
>> just as long to complete as the code I wrote. It still has not
>> completed; however, I am assuming that it will convert Summary Tasks
>> as well. In any case, it is there.
>>
>> Thanks again!
>> JJ
>> On Jan 18, 12:39 pm, "Jan De Messemaeker" <janremovet...@prom-ade.be>
>> wrote:
>>
>>> Tools, Macro, Macros
>>> If you do not see Format duration Macro, Security, set to Low
>>> --
>>> Jan De Messemaeker
>>> Microsoft Project Most Valuable Professional
>>> +32 495 300 620
>>> For availability
>>> check:http://users.online.be/prom-ade/Calendar.pdf"JJ"
>>> <metaldog...@gmail.com> wrote in message
>>> news:d716749f-2fdc-42fb...@h9g2000yqa.googlegroups.co

>>> m... I do not see a "FormatDuration" macro. I am currently using

Gary Chefetz

unread,
Jan 19, 2010, 3:34:25 PM1/19/10
to
JJ:

Lots of RAM will help here. Note that VBA does have an uncorrected memory
leak that causes iterative operations like this to slow down through the
iterations.

--
Gary L Chefetz, MVP, MCT, MCITP
msProjectExperts http://www.msprojectexperts.com
FAQs and Reference http://www.projectserverexperts.com
BLOG: http://projectserverhelp.com

"JJ" <metal...@gmail.com> wrote in message

news:5a058fd3-a184-4453...@21g2000yqj.googlegroups.com...

0 new messages