A
as
I am using some of Jack Dahlgren's code (Posted below with my changes
included) to export to excel the project schedule. When I run the script, any
task more than five levels deep, fails too return any data as set for in the
VBA Code.
Does any7one have any ideas on this, or maybe point me in the right direction.
Jeff
====================================================
'This module contains macros which will export
'tasks to excel and keep the task hierarchy.
'modify as necessary to include other task information
'Copyright Jack Dahlgren, Feb 2002
'===================================== count columns needed
=====================================
ColumnCount = 0
For Each t In ActiveProject.Tasks
If Not t Is Nothing Then
If t.OutlineLevel > ColumnCount Then
ColumnCount = t.OutlineLevel
End If
End If
Next t
'=====================================Set Column Label on Page
===========================
'Set Range to write to first cell
Set xlRow = xlApp.ActiveCell
xlRow = "Filename: " & ActiveProject.Name
Set xlRow = xlRow.Offset(1, 0)
xlRow = "OutlineLevel"
Set xlRow = xlRow.Offset(1, 0)
'label Columns
With xlRow.EntireRow
.Font.Bold = True
.WrapText = False
.Font.ColorIndex = 2
.ColumnWidth = 10
.HorizontalAlignment = xlHAlignCenter
' .VerticalAlignment = xlVAlighnCenter
.AutoFit
' EntireRow.Interior
' .ColorIndex = 1
.Interior.Color = RGB(0, 0, 0)
Pattern = xlSolid
End With
'=====================================Set Headings on Page
===========================
For Columns = 1 To (ColumnCount + 1)
Set xlCol = xlRow.Offset(0, Columns - 1)
xlCol = Columns - 1
Next Columns
Set xlCol = xlCol.Offset(0, 3)
xlCol = "ID"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Duration"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Work"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Actual Work"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Start Date"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Finish Date"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Baseline Finish"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Actual Start Date"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Actual Finish Date"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Predecessors"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Estimated"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Percent Complete"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Over Allocated"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Deadline"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Finish Variance"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Summary Task"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Milestone"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Leveling Delay"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Baseline Start"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Baseline Finish"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Current Target"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "MTP Date"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "BAseline"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "KTP Date"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Risks"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Issues"
Tcount = 0
'================================= Get data
====================================
For Each t In ActiveProject.Tasks
If Not t Is Nothing Then
Set xlRow = xlRow.Offset(1, 0)
Set xlCol = xlRow.Offset(0, t.OutlineLevel)
xlCol = t.Name
If t.Summary Then
xlCol.Font.Bold = True
End If
For Each Asgn In t.Assignments
Set xlRow = xlRow.Offset(0, 0)
Set xlCol = xlRow.Offset(0, Columns)
Set xlCol = xlCol.Offset(0, 1)
xlCol = t.ID
Set xlCol = xlCol.Offset(0, 1)
xlCol = Format((t.Duration / 480), 0#)
Set xlCol = xlCol.Offset(0, 1)
xlCol = FormatNumber((Asgn.Work / 480), 0#)
Set xlCol = xlCol.Offset(0, 1)
xlCol = Format((Asgn.ActualWork / 480), 0#)
Set xlCol = xlCol.Offset(0, 1)
xlCol = Format(Asgn.Start, "SHORT DATE")
Set xlCol = xlCol.Offset(0, 1)
xlCol = Format(Asgn.Finish, "sHORT dATE")
Set xlCol = xlCol.Offset(0, 1)
xlCol = Format(Asgn.BaselineFinish, "sHORT dATE")
Set xlCol = xlCol.Offset(0, 1)
xlCol = Format(Asgn.ActualStart, "SHORT DATE")
Set xlCol = xlCol.Offset(0, 1)
xlCol = Format(Asgn.ActualFinish, "sHORT dATE")
Set xlCol = xlCol.Offset(0, 1)
xlCol = t.Predecessors
Set xlCol = xlCol.Offset(0, 1)
xlCol = t.Estimated
Set xlCol = xlCol.Offset(0, 1)
xlCol = t.PercentWorkComplete
Set xlCol = xlCol.Offset(0, 1)
xlCol = t.Overallocated
Set xlCol = xlCol.Offset(0, 1)
xlCol = t.Deadline
Set xlCol = xlCol.Offset(0, 1)
xlCol = Format((Asgn.FinishVariance / 480), 0#)
Set xlCol = xlCol.Offset(0, 1)
xlCol = t.Summary
Set xlCol = xlCol.Offset(0, 1)
xlCol = t.Milestone
Set xlCol = xlCol.Offset(0, 1)
xlCol = t.LevelingDelay
Set xlCol = xlCol.Offset(0, 1)
xlCol = Format(t.BaselineStart, "SHORT DATE")
Set xlCol = xlCol.Offset(0, 1)
xlCol = Format(t.BaselineFinish, "sHORT dATE")
Set xlCol = xlCol.Offset(0, 1)
xlCol = Format(t.EnterpriseProjectDate1, "SHORT DATE")
'current Target
Set xlCol = xlCol.Offset(0, 1)
xlCol = Format(t.EnterpriseProjectDate2, "sHORT dATE") '
make The Promise
Set xlCol = xlCol.Offset(0, 1)
xlCol = Format(t.EnterpriseProjectDate3, "sHORT dATE")
'Baseline
Set xlCol = xlCol.Offset(0, 1)
xlCol = Format(t.EnterpriseProjectDate4, "sHORT dATE")
'Keep The Promise
xlCol = t.EnterpriseProjectText6
Set xlCol = xlCol.Offset(0, 1)
xlCol = t.EnterpriseProjectText7 '
Set xlCol = xlCol.Offset(0, 1)
Next Asgn
Tcount = Tcount + 1
End If
Next t
included) to export to excel the project schedule. When I run the script, any
task more than five levels deep, fails too return any data as set for in the
VBA Code.
Does any7one have any ideas on this, or maybe point me in the right direction.
Jeff
====================================================
'This module contains macros which will export
'tasks to excel and keep the task hierarchy.
'modify as necessary to include other task information
'Copyright Jack Dahlgren, Feb 2002
'===================================== count columns needed
=====================================
ColumnCount = 0
For Each t In ActiveProject.Tasks
If Not t Is Nothing Then
If t.OutlineLevel > ColumnCount Then
ColumnCount = t.OutlineLevel
End If
End If
Next t
'=====================================Set Column Label on Page
===========================
'Set Range to write to first cell
Set xlRow = xlApp.ActiveCell
xlRow = "Filename: " & ActiveProject.Name
Set xlRow = xlRow.Offset(1, 0)
xlRow = "OutlineLevel"
Set xlRow = xlRow.Offset(1, 0)
'label Columns
With xlRow.EntireRow
.Font.Bold = True
.WrapText = False
.Font.ColorIndex = 2
.ColumnWidth = 10
.HorizontalAlignment = xlHAlignCenter
' .VerticalAlignment = xlVAlighnCenter
.AutoFit
' EntireRow.Interior
' .ColorIndex = 1
.Interior.Color = RGB(0, 0, 0)
Pattern = xlSolid
End With
'=====================================Set Headings on Page
===========================
For Columns = 1 To (ColumnCount + 1)
Set xlCol = xlRow.Offset(0, Columns - 1)
xlCol = Columns - 1
Next Columns
Set xlCol = xlCol.Offset(0, 3)
xlCol = "ID"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Duration"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Work"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Actual Work"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Start Date"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Finish Date"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Baseline Finish"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Actual Start Date"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Actual Finish Date"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Predecessors"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Estimated"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Percent Complete"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Over Allocated"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Deadline"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Finish Variance"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Summary Task"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Milestone"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Leveling Delay"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Baseline Start"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Baseline Finish"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Current Target"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "MTP Date"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "BAseline"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "KTP Date"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Risks"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Issues"
Tcount = 0
'================================= Get data
====================================
For Each t In ActiveProject.Tasks
If Not t Is Nothing Then
Set xlRow = xlRow.Offset(1, 0)
Set xlCol = xlRow.Offset(0, t.OutlineLevel)
xlCol = t.Name
If t.Summary Then
xlCol.Font.Bold = True
End If
For Each Asgn In t.Assignments
Set xlRow = xlRow.Offset(0, 0)
Set xlCol = xlRow.Offset(0, Columns)
Set xlCol = xlCol.Offset(0, 1)
xlCol = t.ID
Set xlCol = xlCol.Offset(0, 1)
xlCol = Format((t.Duration / 480), 0#)
Set xlCol = xlCol.Offset(0, 1)
xlCol = FormatNumber((Asgn.Work / 480), 0#)
Set xlCol = xlCol.Offset(0, 1)
xlCol = Format((Asgn.ActualWork / 480), 0#)
Set xlCol = xlCol.Offset(0, 1)
xlCol = Format(Asgn.Start, "SHORT DATE")
Set xlCol = xlCol.Offset(0, 1)
xlCol = Format(Asgn.Finish, "sHORT dATE")
Set xlCol = xlCol.Offset(0, 1)
xlCol = Format(Asgn.BaselineFinish, "sHORT dATE")
Set xlCol = xlCol.Offset(0, 1)
xlCol = Format(Asgn.ActualStart, "SHORT DATE")
Set xlCol = xlCol.Offset(0, 1)
xlCol = Format(Asgn.ActualFinish, "sHORT dATE")
Set xlCol = xlCol.Offset(0, 1)
xlCol = t.Predecessors
Set xlCol = xlCol.Offset(0, 1)
xlCol = t.Estimated
Set xlCol = xlCol.Offset(0, 1)
xlCol = t.PercentWorkComplete
Set xlCol = xlCol.Offset(0, 1)
xlCol = t.Overallocated
Set xlCol = xlCol.Offset(0, 1)
xlCol = t.Deadline
Set xlCol = xlCol.Offset(0, 1)
xlCol = Format((Asgn.FinishVariance / 480), 0#)
Set xlCol = xlCol.Offset(0, 1)
xlCol = t.Summary
Set xlCol = xlCol.Offset(0, 1)
xlCol = t.Milestone
Set xlCol = xlCol.Offset(0, 1)
xlCol = t.LevelingDelay
Set xlCol = xlCol.Offset(0, 1)
xlCol = Format(t.BaselineStart, "SHORT DATE")
Set xlCol = xlCol.Offset(0, 1)
xlCol = Format(t.BaselineFinish, "sHORT dATE")
Set xlCol = xlCol.Offset(0, 1)
xlCol = Format(t.EnterpriseProjectDate1, "SHORT DATE")
'current Target
Set xlCol = xlCol.Offset(0, 1)
xlCol = Format(t.EnterpriseProjectDate2, "sHORT dATE") '
make The Promise
Set xlCol = xlCol.Offset(0, 1)
xlCol = Format(t.EnterpriseProjectDate3, "sHORT dATE")
'Baseline
Set xlCol = xlCol.Offset(0, 1)
xlCol = Format(t.EnterpriseProjectDate4, "sHORT dATE")
'Keep The Promise
xlCol = t.EnterpriseProjectText6
Set xlCol = xlCol.Offset(0, 1)
xlCol = t.EnterpriseProjectText7 '
Set xlCol = xlCol.Offset(0, 1)
Next Asgn
Tcount = Tcount + 1
End If
Next t