locked
Chose when to run the code in the Global.mpt RRS feed

  • Question

  • HI,

    My users create project.mpp files that run the code in the global.mpt located on each user machine. What can I do so that code runs only when user opens specific projects (projects related to a database that code updates). In other words I don't want to run this code when I open for example an empty .mpp file or any other .mpp file unrelated to the code. I cannot change the current project's naming convention. Is there any other way of recognizing the files on the opening. I tried to set a constant in the project.mpp so I can check against it and run the code if condition is satisfied, but this doesn't work. Thanks in advance.

    Monday, April 14, 2014 2:42 AM

Answers

  • DDrag,

    It could be as simple as the following, just set the Flag1 field of the Project Summary Task as appropriate.

    Private Sub project_open(ByVal pj As MSProject.Project)
    If ProjectSummaryTask.Flag1 Then
    '   [run the code for the database operation]
    End If

    End Sub

    For reference, this code must be placed in ThisProject window of the Project Explorer. Event code does not run as a normal module.

    Hope this helps.

    John


    • Marked as answer by DDrag Thursday, April 17, 2014 11:02 PM
    Monday, April 14, 2014 3:28 PM

All replies

  • DDrag,

    It could be as simple as the following, just set the Flag1 field of the Project Summary Task as appropriate.

    Private Sub project_open(ByVal pj As MSProject.Project)
    If ProjectSummaryTask.Flag1 Then
    '   [run the code for the database operation]
    End If

    End Sub

    For reference, this code must be placed in ThisProject window of the Project Explorer. Event code does not run as a normal module.

    Hope this helps.

    John


    • Marked as answer by DDrag Thursday, April 17, 2014 11:02 PM
    Monday, April 14, 2014 3:28 PM
  • Very simple! Thank you very much.

    It works great.

    Thursday, April 17, 2014 11:02 PM
  • DDrag,

    You're welcome and thanks for the feedback.

    John

    Friday, April 18, 2014 2:12 AM