I have a situation where I need a VBA function to find some information from children tasks. The function works well when I call it from Immediate window in MS Project VBA in Global.MPT. The function is a public function and so i would expect to have access to it from the Formula in the custom field. However, I cannot see it in the lists of possible functions and I get a syntax error when I key it in manually. This is what I key in the formula: SummarryStatus([Unique ID]). I have other functions and subs in Global.mpt which execute when I open the project and when I press the Macro shortcut.
Here is the function although in this case it does not matter what the function is or what it does. I am asking how to call any function for a MS Project custom Field formula.
Public Function SummaryStatus(nT As Long) As String
Dim c As Task
Dim cT As Task, ipT As Task
For Each c In ActiveProject.Tasks(nT).OutlineChildren
If c.PercentComplete = 100 Then
Set cT = c
ElseIf c.PercentComplete <> 0 Then
Set ipT = c
End If
Next c
If Not cT Is Nothing Then
SummaryStatus = cT.Name & " Completed"
ElseIf Not ipT Is Nothing Then
SummaryStatus = ipT.Name & " In Progress"
Else
SummaryStatus = "Not Started"
End If
End Function
Daniel Labelle is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.