none
Run-Time error when calling GanttChartFormat from Application Event (Project Professional 2010) RRS feed

  • Question

  • Newbie here so please forgive any formatting oversights.

    I'm attempting to use an application event to have a change to a task's field automatically update the formatting on the Gantt chart bar.

    Debugging shows that the event is handled correctly and passes the proper arguments, but I get Run-timer error '1100': "The method is not available in this situation." when the GanttBarFormatEx method is called:

    ' In a separate Application Events class that initializes and passes values correctly:

    Private Sub App_ProjectBeforeTaskChange2(ByVal tsk As Task, _ ByVal Field As PjField, _ ByVal NewVal As Variant, _ ByVal Info As EventInfo) Debug.Print "App_ProjectBeforeTaskChange2" If Field = pjTaskText4 And NewVal <> "" Then UpdateColors tsk, NewVal End If End Sub ' --------------------------------------------------------- ' Troublesome code:

    Sub UpdateColors(tsk As Task, sText As Variant) Dim pColor As PjColor Select Case sText Case "Red": pColor = pjRed Case Else: pColor = pjBlue End Select

    debug.print tsk.ID, pColor tsk.Application.GanttBarFormat TaskID:=tsk.ID, endcolor:=pColor End Sub


    I've tried the GanttBarFormat method as well (with and without the preceding tsk.Application) and both App_ProjectBeforeTaskChange & App_ProjectBeforeTaskChange2 but to no avail.

    Also, calling the format method in a "dummy" sub works fine when using the same arguments that are passed to it by the app event.

    A cursory search has turned up a few hits on MSDN and other sites, but I haven't found anything that helps.

    It seems I'm not allowed to insert links yet so here is a relevant MSDN post:

    https://social.msdn.microsoft.com/Forums/en-US/7a606e57-9990-4f59-8911-44a68d3e878a/the-method-is-not-available-in-this-situation-vba?forum=project2010custprog

    Thanks in advance for any help!

    -TD




    • Edited by trevorsd Thursday, May 14, 2015 8:20 PM
    Thursday, May 14, 2015 8:15 PM