View Single Post
 
Old 08-10-2015, 02:50 AM
pascalbidouille pascalbidouille is offline Windows 7 64bit Office 2013
Novice
 
Join Date: Jun 2015
Posts: 18
pascalbidouille is on a distinguished road
Default

Hi Julie, happy you're back. you had good holidays ?

I did investigate on the vba side and manage a macro to do it.
Info in your link would probably have saved me some time, but I still succeeded in extracting data.

Here is my code if anyone may need it
Code:
Sub lire_tache_heure()

Dim tache As Task
Dim taches As Tasks
Dim ressource As Assignment
Dim projet As Project
Dim jour As Date
Dim debut As Date
Dim fin As Date
Dim book
Dim feuille
Dim l As Long
Dim c As Long

Set projet = ActiveProject

Set taches = ActiveSelection.Tasks
Set tache = projet.Tasks.UniqueID(0)
debut = tache.Start
fin = tache.Finish
Set excelappli = CreateObject("Excel.application")
excelappli.Application.workbooks.Add
Set feuille = excelappli.Application.activeworkbook.sheets(1)
feuille.cells.ClearContents
l = 1
c = 5
excelappli.Visible = True
jour = debut
feuille.cells(1, 1).Value = "tache"
feuille.cells(1, 2).Value = "ressource"
feuille.cells(1, 3).Value = "ref1"
feuille.cells(1, 4).Value = "ref2"
While jour < (fin - 1)
    feuille.cells(1, c).Value = jour
    jour = jour + 1
    c = c + 1
Wend

For Each tache In projet.Tasks
    If tache.UniqueID <> 0 Then
        For Each ressource In tache.Assignments
            l = l + 1
            c = 5
            'Debug.Print tache.Name; ressource.ResourceName;
            feuille.cells(l, 1).Value = tache.Name
            feuille.cells(l, 2).Value = ressource.ResourceName
            feuille.cells(l, 3).Value = tache.Text2
            feuille.cells(l, 4).Value = tache.Text3
            jour = debut
            
            While jour < fin - 1
                feuille.cells(l, c).Value = Val(ressource.TimeScaleData(StartDate:=jour, EndDate:=jour + 1, Type:=8, TimeScaleUnit:=4, Count:=1).Item(1).Value) / 60
                
                jour = jour + 1
                c = c + 1
            Wend
        Next
    End If
Next

End Sub
Reply With Quote