J
Jeff
I have succesfully extracted task based data into excel using the method
posted on one of the web sites. I would like however to simply bring back
into excell a list of resources, and the contents of 2 enterprise fields.
The fields are "Enterprise Resource Outline Code" fileds. How do I reference
them? My code is below.
Your HHelp and direction is much appreciated
=====================================================
Sub Get_Resource_Details()
Dim xlRow As Excel.Range
Dim xlCol As Excel.Range
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim Proj As Project
Dim T As task
Dim R As Resource
Dim Asgn As Assignment
Set Proj = ActiveProject
Set xlApp = GetObject(, "Excel.Application")
If xlApp Is Nothing Then
Set xlApp = New Excel.Application
' xlApp.Visible = True
End If
Set xlSheet = xlApp.Worksheets.Add
xlSheet.Name = "Resource Info"
'=====================================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
.AutoFit
.Interior.Color = RGB(0, 0, 0)
Pattern = xlSolid
End With
'=====================================Set Headings on Page
===========================
Set xlCol = xlApp.Range("K3")
xlCol = "Name"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Employee Type"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Job Family"
'================================= Get data
====================================
Set Proj = ActiveProject
For Each R In ActiveProject.Resources
If Not R Is Nothing Then
Set xlRow = xlRow.Offset(1, 0)
Set xlCol = xlRow.Offset(0, 1)
xlCol = R.Name
Set xlRow = xlRow.Offset(0, 0)
Set xlCol = xlRow.Offset(0, 9)
'Set xlCol = xlRow.Offset(0, 9)
Set xcol = xlRow.Range("k1")
Set xlCol = xlCol.Offset(0, 1)
xlCol = R.EnterpriseResourceOutlineCode3
Set xlCol = xlCol.Offset(0, 1)
xlCol = R.JobFamily
Set xlCol = xlCol.Offset(0, 1)
End If
Next R
End Sub
posted on one of the web sites. I would like however to simply bring back
into excell a list of resources, and the contents of 2 enterprise fields.
The fields are "Enterprise Resource Outline Code" fileds. How do I reference
them? My code is below.
Your HHelp and direction is much appreciated
=====================================================
Sub Get_Resource_Details()
Dim xlRow As Excel.Range
Dim xlCol As Excel.Range
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim Proj As Project
Dim T As task
Dim R As Resource
Dim Asgn As Assignment
Set Proj = ActiveProject
Set xlApp = GetObject(, "Excel.Application")
If xlApp Is Nothing Then
Set xlApp = New Excel.Application
' xlApp.Visible = True
End If
Set xlSheet = xlApp.Worksheets.Add
xlSheet.Name = "Resource Info"
'=====================================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
.AutoFit
.Interior.Color = RGB(0, 0, 0)
Pattern = xlSolid
End With
'=====================================Set Headings on Page
===========================
Set xlCol = xlApp.Range("K3")
xlCol = "Name"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Employee Type"
Set xlCol = xlCol.Offset(0, 1)
xlCol = "Job Family"
'================================= Get data
====================================
Set Proj = ActiveProject
For Each R In ActiveProject.Resources
If Not R Is Nothing Then
Set xlRow = xlRow.Offset(1, 0)
Set xlCol = xlRow.Offset(0, 1)
xlCol = R.Name
Set xlRow = xlRow.Offset(0, 0)
Set xlCol = xlRow.Offset(0, 9)
'Set xlCol = xlRow.Offset(0, 9)
Set xcol = xlRow.Range("k1")
Set xlCol = xlCol.Offset(0, 1)
xlCol = R.EnterpriseResourceOutlineCode3
Set xlCol = xlCol.Offset(0, 1)
xlCol = R.JobFamily
Set xlCol = xlCol.Offset(0, 1)
End If
Next R
End Sub