none
MS Project 2013 - TimeScaleData not writing correctly RRS feed

  • Question

  • The issue is when I have to update material work on an assignment that has already data, ie, what I mean is let say that I have previously update one assignment from nov 24 to dec 16 and now I want to update the project using the following VBA code.

    ActiveProject.Tasks.UniqueID(4).Assignments.UniqueID(1048578).TimeScaleData(StartDate:="12/19/17 12:00 AM", EndDate:="12/31/17 12:00 AM", Type:=10, TimeScaleUnit:=4, Count:=13).Item(1).Value = "130"

    The code should tell ms project to put 10 units of the material resource for the next 13 days starting on 12/19 ending on 12/31 (13 days).

    However, for some reason it does not work, the ms project starts writing the first value way before the <g class="gr_ gr_25 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="25" id="25">startdate</g> defined on the code.

    If you see on “picture 1 before running” the actual work finishes on Saturday 16, after running the ms project starts writing on Dec 15 (picture 2 after running), several days before the one defined on the code that is Dec 19.

    However, if I create a for and write day by day it works. But, since I have to update several tasks (like 100) if I have to update day by day of each one of them the time consuming would be huge. If the ms projects <g class="gr_ gr_23 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar multiReplace" data-gr-id="23" id="23">writes</g> once for each task the time would be few seconds.

    Has anyone faced this issue and could give some clues?

    Thanks.

    Picture 1. Before running the code

    Picture 2. After running the code


    PL

    Thursday, November 23, 2017 5:40 PM

Answers

  • Pedro,

    With regard to posting. Pick a forum that seems appropriate. Those of us who monitor the forum will tell you if it is the wrong forum, and as least in my case will suggest a more appropriate forum, but unless you get a response to that effect, wait 24 hours to see if you get a response. If not, either close your post and post elsewhere or leave your original post open but with a note that says you are posting to another forum. Those of us who answer questions on these forums are volunteers and if a user posts to multiple forums, one of us could well be wasting our time if someone else has already answered the question on the other forum.

    I got mixed results with the single statement approach. It seemed to work okay for one and two entries but anything more, the starting index was lost.

    And yes, you will need to add some code to the loop to check for non-working days.

    Hope this helps.

    If my response answered your question please consider marking my response as the answer.

    John

    Thursday, November 23, 2017 11:59 PM

All replies

  • Pedro,

    No need to post a third time. Multiple postings will NOT get you a quicker answer!

    First of all, you apparently are using a 6 day workweek calendar. That means that between 12/19/17 and 12/31/17 there are 11 working days, not 13.

    Second, it looks like you are trying to populate all timescale values with a single statement and that doesn't really work unless you do it one at a time (i.e. your use of Item(1) trying to represent all values). The normal approach to do what you want is with loop in a macro such as the following:

    Option Explicit
    Sub UpdateActualMat()
    Dim AM As TimeScaleValue
    Dim AssVal As TimeScaleValues
    Dim DV As Single
    'find daily allocation (linear) for total material
    DV = 130 / (Application.DateDifference(StartDate:="12/19/17", finishdate:="12/31/17") / 60 / ActiveProject.HoursPerDay)
    Set AssVal = ActiveProject.Tasks.UniqueID(4).Assignments(1).TimeScaleData(StartDate:="12/19/17", _
        EndDate:="12/31/17", Type:=pjAssignmentTimescaledActualWork, timescaleunit:=pjTimescaleDays)
    For Each AM In AssVal
        AM.Value = DV
    Next AM

    End Sub

    Hope this helps.

    John


    • Edited by John - Project Thursday, November 23, 2017 7:01 PM slightly irate
    Thursday, November 23, 2017 6:38 PM
  • Hi Jon

    thanks for your answer and I am sorry for posting it on other forums because I did not know which forum was more adequated. 

    I tried to populate all the timescale values with a single statement because I actually can do that when it is the first time I am writing, i.e., when there are no data recorded (i've done that many times). So, I thought that it was an issue with MS Project.

    I did not want to do it day by day because many times I have over 100 tasks to update and If I have to record an amount day by day for each task it takes a long time.

    Besides, I notice in your code that I also have to check each day if it is a working day otherwise the project is going to write on non-working days as well, right?

    Thanks


    PL

    Thursday, November 23, 2017 9:19 PM
  • Pedro,

    With regard to posting. Pick a forum that seems appropriate. Those of us who monitor the forum will tell you if it is the wrong forum, and as least in my case will suggest a more appropriate forum, but unless you get a response to that effect, wait 24 hours to see if you get a response. If not, either close your post and post elsewhere or leave your original post open but with a note that says you are posting to another forum. Those of us who answer questions on these forums are volunteers and if a user posts to multiple forums, one of us could well be wasting our time if someone else has already answered the question on the other forum.

    I got mixed results with the single statement approach. It seemed to work okay for one and two entries but anything more, the starting index was lost.

    And yes, you will need to add some code to the loop to check for non-working days.

    Hope this helps.

    If my response answered your question please consider marking my response as the answer.

    John

    Thursday, November 23, 2017 11:59 PM