Task ID -1

R

Raquel

Hello,

I am running a macro with an mpp file and it fails because it has a task
with ID -1, does anybody know how this is possible? As far as I know, there
is no way to set up a negative ID, but it already is...

I want to understand how this ID got the value...

Any clue??

Thanks in advance
 
J

Jack Dahlgren

Post the code so we can see what is going on. You should be able to trap for
any task which has a negative ID I would think, so I'd be curious to see what
you are trying to do.

-Jack Dahlgren
 
R

Raquel

Jack,

thanks a lot for your quick answer. I have no problem to ask for negative
ID, what I want to know is how it was introduced in the schedule... Anyway,
here is my code:

For Each R In ActiveProject.Resources
For Each a In R.Assignments
a.Flag1 = False ' this line fails for negative ID
Next a
Next R

I am wondered how the PM sets that value for a taskID...



-------------------------------------------
 
R

Raquel

Hi Jack,

thanks a lot for your quick answer. I have no problem to deal with negative
TaskID. What I am wondered is how the PM set a negative ID for a task... As
far as I know, the ID is an integer number starting with 1.

Anyway, here you are the code.

For Each R In ActiveProject.Resources
For Each a In R.Assignments
a.Flag1 = False ' this line fails and throws an error code 1101
Next a
Next R

Regards,

Raquel
......................................
 
S

Sandro Dadaczynski

Is it possible that you have empty ressourcelines in the resource table???



sandro
 
R

Rod Gill

Try this code and let us know what happens:

Dim Res as Resources
Dim Assgn as Assignment

For Each Res In ActiveProject.Resources
if not res is nothing then
For Each Assgn In Res.Assignments
if not Assgn is nothing then
Assgn.Flag1 = False ' this line fails for negative ID
endif
Next Assgn
endif
Next Res

It's possible you file has a corruption. Do you have any links to other
files in it? If so have you ever moved, over-written or renamed either file?
--

Rod Gill
Microsoft MVP for Project

Author of the only book on Project VBA, see:
http://www.projectvbabook.com
 
R

Raquel

Hi Rod,

thanks for helping me. I run your code. The result is the same: Run-time
error '1101' : The argument value is not valid.
This occurs when Assgn.taskID is -1.

Any clue ?

Thanks in advance,
Raquel
 
R

Raquel

When I do

For Each Task In ActiveProject.Tasks
If (Task.ID = -1) Then
MsgBox ("negative ID")
End If
Next Task

there is no task with negative ID, but when I do

For Each Res In ActiveProject.Resources
If Not Res Is Nothing Then
For Each Assgn In Res.Assignments
If Not Assgn Is Nothing Then
Assgn.Flag1 = False ' this line fails for negative ID
End If
Next Assgn
End If
Next Res

the code fails for records with

? Assgn.taskID
-1
..
I am complety lost...
 
R

Rod Gill

I can only think that you have a corrupted file. Try saving the file as .xml
then re-opening from xml and try the test again.

--

Rod Gill
Microsoft MVP for Project

Author of the only book on Project VBA, see:
http://www.projectvbabook.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top