none
Cancelling Open of Project in the Application_newProject event RRS feed

  • Question

  • I am linking MSProject to a Document management system and am working on the file open event. The problem is when there is a later version of the file when opening. What I want to happen is this:

    if (IsNotLatestVersion)
       
    ShowDialog(LatestVersionMessage)
       
    if(reply == yes)
         
    //cancel Open and open latest version
       
    else if (reply == no)
         
    //Continue opening as normal
       
    else //Cancel
         
    //Cancel opening completely, if no project is open show grey background.

    The problem is I cannot cancel the opening, Application.FileClose does nothing if a project is open and throws an exception when there is no other project open (i.e. opening project by clicking on a file)

    Is there any way of cancelling the file open process to allow the other project file to be opened or the opening process to be cancelled.

    Thanks for any answers.

    Friday, April 20, 2012 11:06 AM

All replies

  • Hi Nymain,

    Thanks for posting in the MSDN Forum.

    I never see the Application.FileClose method in MSProject PIA. I think you might say Application.FileCloseEx method. Is it right? Application.FileCloseEx works fine on my side. I would recommend you clarify your MSProject version and Visual Studio version for further research.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Monday, April 23, 2012 5:03 AM
    Moderator
  • Hi Tom Thanks for your answer.

    My apologies, I do mean FileCloseEx, the reason I cannot use this is it seems to have no effect or throws an error.

    If no documents are open before opening the file I wish to check the version history for (i.e. Double clicking on the file in Explorer rather then a file open, or closing all open projects and using File Open) I get an exception thrown of "The method is not available in this situation".

    I am using Visual Studio 2010 and MSProject 2010.

    Thanks

    Monday, April 23, 2012 8:18 AM
  • Hi Nymain,

    I can reproduce your issue. I will involve some experts into this issue to see whether them can help you. There might be some time delay, thanks for you patience.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, April 24, 2012 7:33 AM
    Moderator
  • Hello NyMain,

    Try this syntax:

    Application.FileCloseAllEx(MSProject.

    PjSaveType.pjDoNotSave,missing);

    It closes the Project file, but not MSProject.


    Chris Jensen

    Wednesday, April 25, 2012 8:46 PM
    Moderator