none
Move tasks programmatically in MSP 2010 RRS feed

  • Question

  •  

    Hello,

    I need to find the way how to move the tasks from one place to another in Microsoft Project Proffesional 2010. 

    This feature is required for my custom addin for Microsoft Project 2010. Unfortunately i haven't found the way how to do this.

    I have created following solution, but it doesn't work on some PC"s.

     

    1) Switch to Gantt Chart View

    2) Select designated tasks in Grid.(Application.SelectRow)

    3) Call Application.EditCopy method

    4) Select required row in the Gantt Chart grid

    5) Call Application.EditPaste

    Please note that i need to move tasks without any limitations..

    May be there is a better way to do this? 

    Thanks in advance.

     

    Tuesday, April 20, 2010 5:41 PM

Answers

  • Hi,
     
    I remember posting an answer to this but it obviously isn't here!
     
    Cut/Paste can be dangerous because new Unique IDs are created. However, the GUID isn't changed (at least for the first paste).
     
    Especially if you have a number of tasks to move, try inserting Number1 and Number2 custom fields (any Number fields will do).
    Copy ID field to Number1 and Number2 (manually or thru code).
    Manually, or using code change sequence of ID's in Number1.
    Sort by Number1 with Renumber option on and all Tasks re-order automatically.
     
    Resort by Number2 to restore original order.

    --

    Rod Gill
    Microsoft MVP for Project - http://www.project-systems.co.nz
     
    Author of the only book on Project VBA, see: http://www.projectvbabook.com
     

     
    "relusion" wrote in message news:09321f4d-1f11-41cc-8112-0421f9679595...

     

    Hello,

    I need to find the way how to move the tasks from one place to another in Microsoft Project Proffesional 2010. 

    This feature is required for my custom addin for Microsoft Project 2010. Unfortunately i haven't found the way how to do this.

    I have created following solution, but it doesn't work on some PC"s.

     

    1) Switch to Gantt Chart View

    2) Select designated tasks in Grid.(Application.SelectRow)

    3) Call Application.EditCopy method

    4) Select required row in the Gantt Chart grid

    5) Call Application.EditPaste

    Please note that i need to move tasks without any limitations..

    May be there is a better way to do this? 

    Thanks in advance.

     



    __________ Information from ESET Smart Security, version of virus signature database 5054 (20100423) __________

    The message was checked by ESET Smart Security.

    http://www.eset.com
    Friday, April 23, 2010 11:05 PM
    Moderator

All replies

  • Hi there. We need more information in order to help. What happens when it "doesn't work on some PCs"?


    Stephen Sanderlin, Project MVP -- MSProjectExperts
    Thursday, April 22, 2010 5:55 PM
    Moderator
  • hi,

    Application.EditPaste fails after SelectRow with the following exception( i am sorry don't remember the exact message): "This method is not available in this situation.".

    Looks like even if SelectRow was called designated row wasn't actually selected and because of that EditPaste Failed.

    Btw, Application.ActiveSelection is being filled with required tasks. 

    I have tried to make some Sleeps and other sync stuff after all i am still have some PC where this approach doesn't work.  

     

    Thursday, April 22, 2010 7:13 PM
  • We need the precise error message along with the HRESULT of the COM error.
    Stephen Sanderlin, Project MVP -- MSProjectExperts
    Friday, April 23, 2010 2:27 PM
    Moderator
  • Hi,
     
    I remember posting an answer to this but it obviously isn't here!
     
    Cut/Paste can be dangerous because new Unique IDs are created. However, the GUID isn't changed (at least for the first paste).
     
    Especially if you have a number of tasks to move, try inserting Number1 and Number2 custom fields (any Number fields will do).
    Copy ID field to Number1 and Number2 (manually or thru code).
    Manually, or using code change sequence of ID's in Number1.
    Sort by Number1 with Renumber option on and all Tasks re-order automatically.
     
    Resort by Number2 to restore original order.

    --

    Rod Gill
    Microsoft MVP for Project - http://www.project-systems.co.nz
     
    Author of the only book on Project VBA, see: http://www.projectvbabook.com
     

     
    "relusion" wrote in message news:09321f4d-1f11-41cc-8112-0421f9679595...

     

    Hello,

    I need to find the way how to move the tasks from one place to another in Microsoft Project Proffesional 2010. 

    This feature is required for my custom addin for Microsoft Project 2010. Unfortunately i haven't found the way how to do this.

    I have created following solution, but it doesn't work on some PC"s.

     

    1) Switch to Gantt Chart View

    2) Select designated tasks in Grid.(Application.SelectRow)

    3) Call Application.EditCopy method

    4) Select required row in the Gantt Chart grid

    5) Call Application.EditPaste

    Please note that i need to move tasks without any limitations..

    May be there is a better way to do this? 

    Thanks in advance.

     



    __________ Information from ESET Smart Security, version of virus signature database 5054 (20100423) __________

    The message was checked by ESET Smart Security.

    http://www.eset.com
    Friday, April 23, 2010 11:05 PM
    Moderator