vbams-project

importing work hours from Excel to MS Project


help me find a macro that can upload working hours by day from excel to MS Project

sample map import

you can help me foud macro for import or maybe work sample. 2. question. I found a macro that clears working hours, but still "0" remains at work instead of "empty", where can there be an error?

Sub ClearActualHours()
Dim tsk As Task
Dim names As String
projStart = ActiveProject.ProjectStart
projEnd = ActiveProject.ProjectFinish
For Each tsk In ActiveProject.Tasks
        Dim asn As Assignment
        For Each asn In tsk.Assignments
            If asn.UniqueID = 2097154 Then
            Dim TSValues As TimeScaleValues
            Set TSValues = asn.TimeScaleData(projStart, projEnd, pjAssignmentTimescaledActualWork, pjTimescaleYears)
                Dim tsv As TimeScaleValue
            For Each tsv In TSValues
          tsv.Clear
         Next tsv
 
        asn.Work = 0    
           End If
Next asn
     Next tsk
End Sub

Solution

  • The reason you are seeing a zero in the Project data is because your macro code explicitly sets it to zero (i.e. asn.Work = 0). I'm not sure if this will work, but you could try something like, asn.Work = " ".

    As far as importing Excel data into Project, take a look at the related questions. One of those can get you started and then if you have further questions, post a new item including the code you are using.