Converting Weeks to Days

J

JJ

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
 
J

JJ

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)
 
A

Andrew Lavinsky

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




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

Jan De Messemaeker

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
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)
 
J

JJ

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
 
J

JJ

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.
 
A

Andrew Lavinsky

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.

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

Gary Chefetz

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top