Share via

Invalid argument on Macro

Anonymous
2011-07-13T22:32:00+00:00

Hi,

I´m running a very simple Macro that assigns a value of 0 to one of Project´s column. I developed it on version 2007 but there is this particular user who has version 2010 and he´s the only one getting the error:

Error 1101 in execution time.

Invalid value argument

The error is being thrown on line highlighted in bold

For Each t In ActiveProject.Tasks

        If Not t Is Nothing Then

            t.Text1 = t.PercentComplete & "%"

        End If

    Next t

    ' set all % completed to 0

    For Each t In ActiveProject.Tasks

    If Not t Is Nothing And Not (t.PercentComplete = 0) Then

t.PercentComplete = 0

    End If

    Next t

It seems like Ms Project won´t let me assign that value to column PercentComplete. However a previous assignment was allowed to column Text1.

Any hints?

Thank you!

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2011-07-14T10:19:03+00:00

Hi,

You cannot set percentcomplete for a summary task.

So your if structure better looks like this:

If not t is nothing then

if (not t.summary) and (t.percentcomplete>0) then

Greetings,

Was this answer helpful?

0 comments No comments

Answer accepted by question author

Anonymous
2011-07-14T00:30:38+00:00

The problem may be in the If Not t Is Nothing And Not (t.PercentComplete = 0) Then line.

If a schedule does have a blank row, then the Not t is Nothing returns False, but teh t.PercentComplete fails. Try:

For Each t In ActiveProject.Tasks

    If Not t Is Nothing Then

        If t.PercentComplete <> 0  Then

t.PercentComplete = 0

        End If

    End If

Next t

Was this answer helpful?

0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2011-07-18T22:32:24+00:00

    i implemented suggestions from both Jan and Rod. That solve the problem.

    Thanks a lot!

    Was this answer helpful?

    0 comments No comments