none
Macro-ScheduleFinish randomly only showing date - not time and crashing my macro RRS feed

  • Question

  • If Not ((CStr(ActiveProject.Tasks(Temp).ScheduledFinish) Like "") Or CStr(ActiveProject.Tasks(Temp).ScheduledFinish) Like "NA")) Then
              Tsk("SchedFinish") = tomillidate(CStr(ActiveProject.Tasks(Temp).ScheduledFinish))
              Tsk("SchedFinishT") = totime(CStr(ActiveProject.Tasks(Temp).ScheduledFinish))
    End If
    
    Function totime(dat As String) As String
    'Converts this format 5/4/2018 5:00:00 PM  to PT14H39M40S
    Dim parts() As String
    
    If Not ((dat Like "") Or (dat Like "NA")) Then
          parts(1) = parts(1) & parts(2)
          totime = Format(parts(1), "\P\THh\Hmm\Mss\S")
    Else
    
        totime = "NA"
        
    End If
    
    End Function

    If there is no time in ScheduleFinish - it crashes.  Have no idea why there is no time - although I'm ok with a generic time if the time isn't set.  For 80% of my projects, only looking at days.  I do have that 20% though...

    I don't know if this is the right way of converting all together???

    Any help is appreciated!

    Saturday, August 24, 2019 12:53 PM

Answers

  • John,

    ScheduleFinish missing a time is literally what my issue is in the macro.  3rd task in my plan, first that's not a summary task and is scheduled off of the project start doesn't have a time, while the rest of the tasks do.  If the time was 0, I could handle it.  The time is actually not there as the field ends with the date - 8 characters rather than 16 or so that I would see for other tasks.

    Because there is no time, the split doesn't give me 3 parts, and addressing part(2) abends the macro.

    I've now changed the code to do a string search for a : before splitting the field at all.  

    Tim

    • Marked as answer by TimBarrow Saturday, August 24, 2019 6:33 PM
    Saturday, August 24, 2019 6:33 PM

All replies

  • TimBarrow,

    Project stores all date data in minutes so there will always be a time associated with any date. Whether or not the time is displayed is determined by the Date Format in Project's General options.

    Also, except for extra date fields (e.g. Date1, Start1, etc.) there will always be a date (i.e. never a blank or NA). Note that the Start and Finish fields are text fields. For auto scheduled tasks a date is displayed but for manually scheduled tasks, those fields may be blank or have a pseudo date (i.e. "today").

    From the limited code snippet you show, it's not at all clear as to what you are trying to do. If you give us a more detailed explanation then we are in a better position to provide help. It would also be useful to know which version of Project you are using.

    Just for reference, I notice that you have three posts to a couple of Project forums since you signed up in 2015. Answers/suggestions were provided but no response from you. Without some type of feedback we have no way of knowing if we helped.

    John


    Saturday, August 24, 2019 4:13 PM
  • John,

    ScheduleFinish missing a time is literally what my issue is in the macro.  3rd task in my plan, first that's not a summary task and is scheduled off of the project start doesn't have a time, while the rest of the tasks do.  If the time was 0, I could handle it.  The time is actually not there as the field ends with the date - 8 characters rather than 16 or so that I would see for other tasks.

    Because there is no time, the split doesn't give me 3 parts, and addressing part(2) abends the macro.

    I've now changed the code to do a string search for a : before splitting the field at all.  

    Tim

    • Marked as answer by TimBarrow Saturday, August 24, 2019 6:33 PM
    Saturday, August 24, 2019 6:33 PM
  • TimBarrow,

    Okay...... What you wrote makes absolutely no sense to me, and most likely anybody else, because it lacks context (i.e. enough background detail such that a third party can understand). However, it sounds like you found a solution and that's good.

    John

    Saturday, August 24, 2019 9:44 PM