T
Tuva
I am trying to customize a Project Pro file with some VBA code.
Specifically, I want to change the color of a task based on a user's entry
in a text column. I've attached some code to the ProjectBeforeTaskChange
event. The event fires just right but I do not seem to be able to address
the SelectRow property from the Application project without generating an
error. Here is the code:
----------- MyEvents (Class Module)
Public WithEvents App As Application
Private Sub App_ProjectBeforeTaskChange(ByVal tsk As Task, ByVal Field As
PjField, ByVal NewVal As Variant, Cancel As Boolean)
If Field = pjTaskText1 Then
TaskText = NewVal
If TaskText = "Active" Then
App.SelectRow row:=tsk, RowRelative:=False
Font Color:=1
Else
App.SelectRow row:=tsk, RowRelative:=False
Font Color:=4
End If
End If
End Sub
------------- MyModule (Module)
Dim AppEvents As New MyEvents
Sub BindEventToApplication()
Set AppEvents.App = Application
End Sub
The lines App.SelectRow row:=tsk, RowRelative:False always generate this
error:
Run-time error 1100:
The method is not available in this situation
I have verified that the variable App is indeed accessable in the event. For
example, code such as "i = App.Projects.Count" operates just fine.
I am stumped and must be missing something obvious, help anyone?!
Jib
Specifically, I want to change the color of a task based on a user's entry
in a text column. I've attached some code to the ProjectBeforeTaskChange
event. The event fires just right but I do not seem to be able to address
the SelectRow property from the Application project without generating an
error. Here is the code:
----------- MyEvents (Class Module)
Public WithEvents App As Application
Private Sub App_ProjectBeforeTaskChange(ByVal tsk As Task, ByVal Field As
PjField, ByVal NewVal As Variant, Cancel As Boolean)
If Field = pjTaskText1 Then
TaskText = NewVal
If TaskText = "Active" Then
App.SelectRow row:=tsk, RowRelative:=False
Font Color:=1
Else
App.SelectRow row:=tsk, RowRelative:=False
Font Color:=4
End If
End If
End Sub
------------- MyModule (Module)
Dim AppEvents As New MyEvents
Sub BindEventToApplication()
Set AppEvents.App = Application
End Sub
The lines App.SelectRow row:=tsk, RowRelative:False always generate this
error:
Run-time error 1100:
The method is not available in this situation
I have verified that the variable App is indeed accessable in the event. For
example, code such as "i = App.Projects.Count" operates just fine.
I am stumped and must be missing something obvious, help anyone?!
Jib