Move MsProject Task to another location with C# RRS feed

  • Question

  • I want to move tasks inside an mpp.

    I recorded a Macro when doing this by mouse. It works perfect ( it copies all fields including custom-text-fields)

    Sub Macro12()
        SelectRow Row:=25
        SelectRow Row:=18
    End Sub

    If I execute the same operations via COM-Api (via C#) then I loose custom-fields.

    Any advice?

    • Edited by Somigur Wednesday, December 4, 2019 10:21 PM
    Wednesday, December 4, 2019 10:03 PM

All replies

  • You have to select the whole row. If you only select visible cells you will only copy the visible cells.

    Rod Gill
    Author of the one and only Project VBA Book and VBA developer.

    Thursday, December 12, 2019 9:02 AM
  • How can I select "EntireRow" in MS-Project?

    I am aware of "EntireRow"-Selection in Excel only

    Friday, December 13, 2019 2:29 PM
  • Somigur,

    I'm not quite sure what Rod is referring to as the statement SelectRow DOES select the entire row, including fields that may not be visible in the view, even if the active selection is a single cell. However, there is a little more to the SelectRow Method. By default, the row selected will be relative to the current active row or cell. So if the active cell is the Name field of task ID 10, your code will select task row 35, and if your file is filtered, grouped or sorted, that may not be Task ID 35. Remember, select methods work on the active view.

    IF you haven't already, I suggest you take a look at the Project VBA Object browser to get more details about the SelectRow Method.

    With regard to your original question about why its not working in a C# environment, I do use C# so I can't help you with that. Hopefully someone else will jump in with assistance.


    Friday, December 13, 2019 6:27 PM
  • I suspect when converting from VBA to C# only visible cells are selected.

    SelectRow is a method belonging to the Application object.

    Rod Gill
    Author of the one and only Project VBA Book and VBA developer.

    Saturday, December 14, 2019 9:15 AM