none
Struggling with changing Active Cell Value RRS feed

  • Question

  • Here is the situation:

    I am working on project server and let's say one of the requirement is Project managers who access the project through project professional pro on desktop or through the schedule web part in project web app can only do the following

    1.) They can only change the % completed column. nothing else can be changed

    I do realize there is no disabling columns etc in project so, I am going down the path of writing a MACRO and my logic is

    • Let's say a user changes a column other than % completed, then to change the active cells value to the old value

    I can find the new value because i am using the App_ProjectBeforeTaskChange sub routine and NewVal i have

    I can find the old value by doing ActiveCell.Text

    but how do i set the active cell value back to let's say "Hello", i have tried this. here if they change the task name i want to set it to say hello..but it never does, the other values i am able to..

    Any help ???

    Private Sub App_ProjectBeforeTaskChange(ByVal tsk As Task, ByVal Field As PjField, ByVal NewVal As Variant, Cancel As Boolean)
        
        Dim originalTask As Task
        Set originalTask = ActiveCell.Task
        Dim row As String
        
        If (Field = pjTaskName) Then
            'ActiveCell.Task.SetField FieldID:=pjTaskName, Value:="Hello"
            
        End If
        
    End Sub


    Thursday, October 22, 2015 4:31 PM

All replies

  • Changing a field value during its BeforeChange event can have strange results. You can put up a message and set Cancel to True to keep the value from changing. The old value will still be in tsk (tsk.Name in your example). BTW, tsk is the task that's being changed so you don't have to worry about ActiveCell.Task.

    Thursday, October 22, 2015 9:14 PM
  • In case of not allowing the user to change the field,
    you set the variable Cancel = true.

    This will not restore the original value of the field
    but leave the user in the field with the changed value.

    Therefore, the only way forward is the user hitting
    the esc button - that restores the original value.

    On the event you could do the following:

    1) Cancel the task change

    2) Display a dialogue box to the end user - saying
    that he off limits and need to hit the escape button


    Best Regards | EPMPARTNER |
    http://www.epmpartner.dk

    Friday, October 23, 2015 5:34 PM
  • Is this the only way this can be done in "MS Project 2016"?  

    Asking a user to click escape seems too inefficient.

    Regards,

    Agasthya


    agasthya

    Tuesday, March 27, 2018 5:28 AM