none
How can I activate an open MS Project File (MPP) RRS feed

  • Question

  • I am using Microsoft.Office.Interop.MSProject to work with MPP files. My requirement is to open mutliple mpp files in Application objects and update them as required. However, The last opened mpp file is always set as ActiveProject. Due to which all updations are made to last MPP file.

    I tried using Project.Activate() but I get exception. How can I activate desired project (MPP) on demand by keeping multiple files open in 'Application' object?

    I am using VS2010, .NET Framework 4.0, Microsoft Project 14.0 Object Library.

    Monday, August 19, 2013 8:41 AM

All replies

  • I develop in VBA rather than VB.Net, and know the pj.activate works there, although it doesn't get the brackets in VBA. Maybe try without the brackets.

    However, you only really need to activate projects for foreground processing. If you want to perform a background action on all open projects, you can loop through the application.projects collection as shown below. A lot of actions can be undertaken without activating the project. If you do need to activeate the project, in VBA the command would just be pj.activate

    Sub LoopThroughOpenProjects() Dim pj As Project For Each pj In Application.Projects 'do stuff for each project here
    Debug.Print "Project Name - " & pj.name Next pj End Sub

    Hope this is helpful.

    Andrew

    Monday, August 19, 2013 11:05 AM
  • Hi,

    his is how I do it.

    I try to avoid editing the activeproject.

    When I open a project, I give it a name:

    Dim ProjectXX as project

    setProjectxx=activeproject

    Then updates look like (f.i.)

    projectxx.tasks(5).text22="OK"

    This way you always address the right file.

    Greetings,

    Monday, August 19, 2013 6:51 PM
    Moderator