0

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?

3
  • By wrapping the 0 in double quotations marks, you are changing it from an integer to a string. Commented Mar 5, 2020 at 15:21
  • 1
    @Mech - from the docs, a string is expected. Commented Mar 5, 2020 at 15:21
  • Solved my own question. See below Commented Mar 5, 2020 at 15:35

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.