Move tasks programmatically in MSP 2010
-
2010年4月20日 17:41
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.
すべての返信
-
2010年4月22日 17:55モデレータ
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 -
2010年4月22日 19:13
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.
-
2010年4月23日 14:27モデレータWe need the precise error message along with the HRESULT of the COM error.
Stephen Sanderlin, Project MVP -- MSProjectExperts- 編集済み Stephen Sanderlin [MVP]Moderator 2010年4月23日 14:27 typo
-
2010年4月23日 23:05モデレータ
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.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- 回答としてマーク Stephen Sanderlin [MVP]Moderator 2010年4月28日 4:07