locked
Active project programmatically when more than one project is open RRS feed

  • Question

  • Hi, I am trying to switch projects programmatically; all attempts have failed.

     

    Calls to :  ProjectApplication.ActiveProject return a "Invalid type" even after I have specifically type cast my object.

    The user has two or more projects open and I want to switch to a specific on, any clues ?

     


    Paul Usher Usher.Net Pty Ltd "software by design"
    Friday, September 3, 2010 7:01 AM

Answers

  • Hi,

    I suppose you ar talking VBA? It would be helpful if you specify that.

    As long as any project is open, Active Project does not return an error. OTOH, I do not know anything called ProjectApplication. Did you define that from an other application? In VBA Project you just use Application. or simply ActiveProject

    As for activating an other project, the method is Project.Activate; suppose the project to be activated has been defined as the project object ThePr that would read ThePr.activate

    There are a few more examples in the help on the activate method

    Friday, September 3, 2010 9:46 AM

All replies

  • Hi,

    I suppose you ar talking VBA? It would be helpful if you specify that.

    As long as any project is open, Active Project does not return an error. OTOH, I do not know anything called ProjectApplication. Did you define that from an other application? In VBA Project you just use Application. or simply ActiveProject

    As for activating an other project, the method is Project.Activate; suppose the project to be activated has been defined as the project object ThePr that would read ThePr.activate

    There are a few more examples in the help on the activate method

    Friday, September 3, 2010 9:46 AM
  • Inside VB.Net 2010, I have an instance of the application (called ProjectApplication), 

    The solution is actually to iterate the ProjectApplication.Projects collection, testing the name of each entry to see if it matches what I am looking for, if so, then call ProjectApplication.Projects(index).Activate.

     

    The problem in the Object library is that whilst ProjectApplication is overloaded with index as integer as well as project as project, it only works with the integer parameter.

     

    Please consider this problem closed.

     

    Thanks for your input.

     

    Paul.


    Paul Usher Usher.Net Pty Ltd "software by design"
    Wednesday, September 8, 2010 4:56 AM
  • Hi,

    projects("Project2").Activate works fine in VBA, so if it doesn't work in the equivalent code in VB then it's a bug.

    Rod Gill


    The one and only Project VBA Book Rod Gill Project Management
    Wednesday, September 8, 2010 5:05 AM