Getting to the "Resouce Initials" 
Author Message
 Getting to the "Resouce Initials"

Hi all,
I am new to VBA but have been able to piece together (thanks to this
group!)the code at the end of this post.

It bascically prints out the following report for all resources:

Month,Project,Workorder,AppCode,Resource,Hours,TaskName
May,Project1,SDS000411.1,CCD,Mike Teal,4,Task1
May,Project1,SDS000511.1,CCD,Dave Mills,25,Task1
May,Project2,SDS000611.1,CCD,Mike Teal,6,Task2
May,Project2,SDS000711.1,CCD,Doreen Ward,9,Task3
May,Project3,SDS000811.1,CCD,Mark Brown,10,Task4

I then take this and put it into Excell and can then manipulate the
data for various other reports.

I would like to substitute the "Rsource Name" I get with the "Resource
Initials". The resource name is coming from the assignement object,
but it seems I need to somehow get to the resources object to get the
resource initials. How do I get it from there?

Any suggestions will definitly help! Also any comments on how this is
coded in general will be appreciated as I am just learning VBA.

Thanks!
Kumar

**** Start Code
Sub MyActuals()
    Dim tsk As Task
    Dim asn As Assignment
    Dim tsv As TimeScaleValue
    Dim f As Integer
    Dim sf As String
    Dim OutlineTask As String
    Dim OutlineTaskName As String
    Dim OutlineResource As String
    Dim OutlineTimephase As String
    Dim strProjectName As String
    Dim intCount As Integer
    Dim dtStartDate As Date
    Dim dtEndDate As Date
    Dim strMonth As String

    f = FreeFile
    Outline = ""

    'MUST enter these parameters for each month report:
    dtStartDate = "05/01/2001"
    dtEndDate = "05/31/2001"
    strMonth = "May"

    'Create Output file based on Month
    sf = "C:\Projects\MyActuals-" & strMonth & ".txt"
    Open sf For Output As #f

    'Print field titles:
    Print #f, "Month" & "," & "Project" & "," & "Workorder" & "," &
"AppCode" & "," & "Resource" & "," & "Hours" & "," & "TaskName"

    'Print assignments
    For Each tsk In ActiveProject.Tasks

        If Not tsk Is Nothing Then

             If tsk.OutlineLevel = 1 Then
                strProjectName = tsk.Name
             End If

             OutlineTaskName = tsk.Name
             OutlineTask = strMonth & "," & strProjectName & "," &
tsk.GetField(pjTaskText1) & "," & tsk.GetField(pjTaskText2)

            For Each asn In tsk.Assignments

                Debug.Print , asn.ResourceName

                OutlineResource = asn.ResourceName

                For Each tsv In
asn.TimeScaleData(StartDate:=dtStartDate, EndDate:=dtEndDate,
Type:=pjAssignmentTimescaledActualWork,
timescaleunit:=pjTimescaleMonths, Count:=1)
                    Debug.Print Val(tsv.Value) / 60,
                    OutlineTimephase = (Val(tsv.Value) / 60)
                Next
                Debug.Print OutlineTask & "," & OutlineResource & ","
& OutlineTimephase
                Print #f, OutlineTask & "," & OutlineResource & "," &
OutlineTimephase & ","; OutlineTaskName
            Next
        End If
    Next
    Close

End Sub
**** EndCode



Sun, 30 Nov 2003 07:43:41 GMT  
 Getting to the "Resouce Initials"
Hi,

The following code might help

Sub test()
Dim A As Assignment
Dim R As Resource

For Each R In ActiveProject.Resources
    For Each A In R.Assignments
        Debug.Print A.TaskName, R.Name, R.Initials
    Next
Next

End Sub

--

Visit www.mvps.org/project/ for the Project MVP's FAQ and third party
add-ons

Rod Gill
Microsoft Project MVP
Visit www.projectlearning.com for customized Project and Ofice VBA macros
and Project companion software


Quote:
> Hi all,
> I am new to VBA but have been able to piece together (thanks to this
> group!)the code at the end of this post.

> It bascically prints out the following report for all resources:

> Month,Project,Workorder,AppCode,Resource,Hours,TaskName
> May,Project1,SDS000411.1,CCD,Mike Teal,4,Task1
> May,Project1,SDS000511.1,CCD,Dave Mills,25,Task1
> May,Project2,SDS000611.1,CCD,Mike Teal,6,Task2
> May,Project2,SDS000711.1,CCD,Doreen Ward,9,Task3
> May,Project3,SDS000811.1,CCD,Mark Brown,10,Task4

> I then take this and put it into Excell and can then manipulate the
> data for various other reports.

> I would like to substitute the "Rsource Name" I get with the "Resource
> Initials". The resource name is coming from the assignement object,
> but it seems I need to somehow get to the resources object to get the
> resource initials. How do I get it from there?

> Any suggestions will definitly help! Also any comments on how this is
> coded in general will be appreciated as I am just learning VBA.

> Thanks!
> Kumar

> **** Start Code
> Sub MyActuals()
>     Dim tsk As Task
>     Dim asn As Assignment
>     Dim tsv As TimeScaleValue
>     Dim f As Integer
>     Dim sf As String
>     Dim OutlineTask As String
>     Dim OutlineTaskName As String
>     Dim OutlineResource As String
>     Dim OutlineTimephase As String
>     Dim strProjectName As String
>     Dim intCount As Integer
>     Dim dtStartDate As Date
>     Dim dtEndDate As Date
>     Dim strMonth As String

>     f = FreeFile
>     Outline = ""

>     'MUST enter these parameters for each month report:
>     dtStartDate = "05/01/2001"
>     dtEndDate = "05/31/2001"
>     strMonth = "May"

>     'Create Output file based on Month
>     sf = "C:\Projects\MyActuals-" & strMonth & ".txt"
>     Open sf For Output As #f

>     'Print field titles:
>     Print #f, "Month" & "," & "Project" & "," & "Workorder" & "," &
> "AppCode" & "," & "Resource" & "," & "Hours" & "," & "TaskName"

>     'Print assignments
>     For Each tsk In ActiveProject.Tasks

>         If Not tsk Is Nothing Then

>              If tsk.OutlineLevel = 1 Then
>                 strProjectName = tsk.Name
>              End If

>              OutlineTaskName = tsk.Name
>              OutlineTask = strMonth & "," & strProjectName & "," &
> tsk.GetField(pjTaskText1) & "," & tsk.GetField(pjTaskText2)

>             For Each asn In tsk.Assignments

>                 Debug.Print , asn.ResourceName

>                 OutlineResource = asn.ResourceName

>                 For Each tsv In
> asn.TimeScaleData(StartDate:=dtStartDate, EndDate:=dtEndDate,
> Type:=pjAssignmentTimescaledActualWork,
> timescaleunit:=pjTimescaleMonths, Count:=1)
>                     Debug.Print Val(tsv.Value) / 60,
>                     OutlineTimephase = (Val(tsv.Value) / 60)
>                 Next
>                 Debug.Print OutlineTask & "," & OutlineResource & ","
> & OutlineTimephase
>                 Print #f, OutlineTask & "," & OutlineResource & "," &
> OutlineTimephase & ","; OutlineTaskName
>             Next
>         End If
>     Next
>     Close

> End Sub
> **** EndCode



Sun, 30 Nov 2003 13:01:09 GMT  
 Getting to the "Resouce Initials"
Thank you! I works as is. Now I will see if I can incorporate it into what I am doing...
-Kumar
Quote:

> Hi,

> The following code might help

> Sub test()
> Dim A As Assignment
> Dim R As Resource

> For Each R In ActiveProject.Resources
>     For Each A In R.Assignments
>         Debug.Print A.TaskName, R.Name, R.Initials
>     Next
> Next

> End Sub

> --

> Visit www.mvps.org/project/ for the Project MVP's FAQ and third party
> add-ons

> Rod Gill
> Microsoft Project MVP
> Visit www.projectlearning.com for customized Project and Ofice VBA macros
> and Project companion software



> > Hi all,
> > I am new to VBA but have been able to piece together (thanks to this
> > group!)the code at the end of this post.

> > It bascically prints out the following report for all resources:

> > Month,Project,Workorder,AppCode,Resource,Hours,TaskName
> > May,Project1,SDS000411.1,CCD,Mike Teal,4,Task1
> > May,Project1,SDS000511.1,CCD,Dave Mills,25,Task1
> > May,Project2,SDS000611.1,CCD,Mike Teal,6,Task2
> > May,Project2,SDS000711.1,CCD,Doreen Ward,9,Task3
> > May,Project3,SDS000811.1,CCD,Mark Brown,10,Task4

> > I then take this and put it into Excell and can then manipulate the
> > data for various other reports.

> > I would like to substitute the "Rsource Name" I get with the "Resource
> > Initials". The resource name is coming from the assignement object,
> > but it seems I need to somehow get to the resources object to get the
> > resource initials. How do I get it from there?

> > Any suggestions will definitly help! Also any comments on how this is
> > coded in general will be appreciated as I am just learning VBA.

> > Thanks!
> > Kumar

> > **** Start Code
> > Sub MyActuals()
> >     Dim tsk As Task
> >     Dim asn As Assignment
> >     Dim tsv As TimeScaleValue
> >     Dim f As Integer
> >     Dim sf As String
> >     Dim OutlineTask As String
> >     Dim OutlineTaskName As String
> >     Dim OutlineResource As String
> >     Dim OutlineTimephase As String
> >     Dim strProjectName As String
> >     Dim intCount As Integer
> >     Dim dtStartDate As Date
> >     Dim dtEndDate As Date
> >     Dim strMonth As String

> >     f = FreeFile
> >     Outline = ""

> >     'MUST enter these parameters for each month report:
> >     dtStartDate = "05/01/2001"
> >     dtEndDate = "05/31/2001"
> >     strMonth = "May"

> >     'Create Output file based on Month
> >     sf = "C:\Projects\MyActuals-" & strMonth & ".txt"
> >     Open sf For Output As #f

> >     'Print field titles:
> >     Print #f, "Month" & "," & "Project" & "," & "Workorder" & "," &
> > "AppCode" & "," & "Resource" & "," & "Hours" & "," & "TaskName"

> >     'Print assignments
> >     For Each tsk In ActiveProject.Tasks

> >         If Not tsk Is Nothing Then

> >              If tsk.OutlineLevel = 1 Then
> >                 strProjectName = tsk.Name
> >              End If

> >              OutlineTaskName = tsk.Name
> >              OutlineTask = strMonth & "," & strProjectName & "," &
> > tsk.GetField(pjTaskText1) & "," & tsk.GetField(pjTaskText2)

> >             For Each asn In tsk.Assignments

> >                 Debug.Print , asn.ResourceName

> >                 OutlineResource = asn.ResourceName

> >                 For Each tsv In
> > asn.TimeScaleData(StartDate:=dtStartDate, EndDate:=dtEndDate,
> > Type:=pjAssignmentTimescaledActualWork,
> > timescaleunit:=pjTimescaleMonths, Count:=1)
> >                     Debug.Print Val(tsv.Value) / 60,
> >                     OutlineTimephase = (Val(tsv.Value) / 60)
> >                 Next
> >                 Debug.Print OutlineTask & "," & OutlineResource & ","
> > & OutlineTimephase
> >                 Print #f, OutlineTask & "," & OutlineResource & "," &
> > OutlineTimephase & ","; OutlineTaskName
> >             Next
> >         End If
> >     Next
> >     Close

> > End Sub
> > **** EndCode



Mon, 01 Dec 2003 01:17:21 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Detecting closing of "user initials" form

2. *"*-.,._,.-*"* I"LL TRADE VISUAL C++ FOR VBASIC *"*-.,_,.-*"*

3. GetObject("","InternetExplorer.Application") fails in Excel VBA

4. CopyObject gets "Illegal function call" error

5. SysCmd 603, "path","path"

6. Getting Current Paragraph "Level"

7. getting "dir" output into arrays

8. Getting "lucky" with women using VB

9. Getting "Changed database context" error

10. Getting the "Generated Preview"

11. Getting a form "always on top"

12. Getting "Send To" functionality

 

 
Powered by phpBB® Forum Software