none
Project 2013 and SplitParts RRS feed

  • Question

  • I need programatically connect splited task. How can i do it correctly?

    I find task.splitparts. And I try to use:

    while task.splitparts.count > 1 do begin

      task.splitparts[count].delete

    end;

    But I await that last splitpart recalcucate start and finish correctly and it is not true. Finish of last splitpart is not moved to correct date after deleting other spitparts.

    So what is correct way to delete splits in splited tasks?

    Friday, May 3, 2013 8:39 AM

Answers

  • I tried the following from Excel VBA:

    Sub Test()
    Dim PrjApp As New MSProject.Application
        Set PrjApp = GetObject(, "MSProject.Application")
        PrjApp.ActiveProject.Tasks(1).SplitParts(2).Start = ActiveProject.Tasks(1).SplitParts(1).Finish
        Set PrjApp = Nothing
    End Sub

    So nothing wrong with OLE automation. Suspect Delphi implementation of it.

    You can create macros in Project and call them from Delphi: prjApp.Run "MacroName"

    Macros stored in Global.mpt available for all open projects.


    Rod Gill

    The one and only Project VBA Book

    Rod Gill Project Management

    • Marked as answer by Dan.Fo Monday, May 6, 2013 11:25 AM
    • Unmarked as answer by Dan.Fo Monday, May 6, 2013 11:25 AM
    • Marked as answer by Dan.Fo Monday, May 6, 2013 11:26 AM
    Friday, May 3, 2013 10:15 PM
    Moderator

All replies

  • Just tested and this worked for me:

    ActiveProject.Tasks(1).SplitParts(2).Start=ActiveProject.Tasks(1).SplitParts(1).Finish


    Rod Gill

    The one and only Project VBA Book

    Rod Gill Project Management

    Friday, May 3, 2013 9:56 AM
    Moderator
  • I use it through OLE automation by external application. And it does not work here.

    I use it in Delphi 2007 as MSPROJECT_TBL.pas type library. When i write:

    while FSplitParts.Count > 1 do begin
      MySplitPart.ConnectTo(SplitPartDisp(FSplitParts.DefaultInterface.Item[FSplitParts.Count]));
      MySplitPart2.ConnectTo(SplitPartDisp(FSplitParts.DefaultInterface.Item[FSplitParts.Count - 1]));
      MySplitPart.DefaultInterface.Start := MySplitPart2.DefaultInterface.Finish;
    end;

    It ends in no-ending loop. FSplitParts.Count is still 2 and MySplitPart.DefaultInterface.Start does not changed by setting MySplitPart.DefaultInterface.Start := MySplitPart2.DefaultInterface.Finish.

    Friday, May 3, 2013 11:59 AM
  • In the same situation alghoritm:

    while FSplitParts.Count > 1 do begin
      MySplitPart.ConnectTo(SplitPartDisp(FSplitParts.DefaultInterface.Item[FSplitParts.Count]));
      MySplitPart.DefaultInterface.Delete;
    end;

    works partially correctly. It delete extra splitparts. But because of bad finish in splitpart[1] it make some problems later. It looks that there are some problems in OLE automation for:

    MySplitPart.DefaultInterface.Start

    MySplitPart.DefaultInterface.Finish

    MySplitPart.DefaultInterface.Delete

    Friday, May 3, 2013 12:06 PM
  • I tried the following from Excel VBA:

    Sub Test()
    Dim PrjApp As New MSProject.Application
        Set PrjApp = GetObject(, "MSProject.Application")
        PrjApp.ActiveProject.Tasks(1).SplitParts(2).Start = ActiveProject.Tasks(1).SplitParts(1).Finish
        Set PrjApp = Nothing
    End Sub

    So nothing wrong with OLE automation. Suspect Delphi implementation of it.

    You can create macros in Project and call them from Delphi: prjApp.Run "MacroName"

    Macros stored in Global.mpt available for all open projects.


    Rod Gill

    The one and only Project VBA Book

    Rod Gill Project Management

    • Marked as answer by Dan.Fo Monday, May 6, 2013 11:25 AM
    • Unmarked as answer by Dan.Fo Monday, May 6, 2013 11:25 AM
    • Marked as answer by Dan.Fo Monday, May 6, 2013 11:26 AM
    Friday, May 3, 2013 10:15 PM
    Moderator