viviansplatoon
viviansplatoon

Reputation: 148

Invalid argument value error when setting MS Project task field

In Excel VBA, I'm getting this error all of a sudden:

Run-timer error 1101: The argument value is not valid.

I'm trying to set all the Percent Work Complete fields of tasks from Microsoft Project to 0. The error occurs in this block of code:

    Dim t As Task
    Dim row As Variant
    For Each row In tasksDict.Keys
        If tasksDict(row).Active Then
            Set t = tasksDict(row)
            t.SetField FieldID:=188743713, Value:=0 ' ERROR HERE (sets the Percent Work Complete field)
        End If
    Next row

It doesn't work if I do this either:

t.SetField FieldID:=188743713, Value:="0"

Can anyone help me figure out what a valid value would be?

Edit: Note that this code was working up until today. Could this be a bug on Microsoft's end?

Upvotes: 0

Views: 2072

Answers (1)

viviansplatoon
viviansplatoon

Reputation: 148

Solved. Upon reading the docs, I realized you cannot set the Percent Work Complete field of summary tasks so I added an extra if-statement in my code:

Dim t As Task
Dim row As Variant
For Each row In tasksDict.Keys
    If tasksDict(row).Active Then
        Set t = tasksDict(row)
        If Not t.Summary Then
            t.SetField FieldID:=188743713, Value:=0 ' ERROR HERE (sets the Percent Work Complete field)
        End If
    End If
Next row

Upvotes: 1

Related Questions