Error 2147417848

N

Nicole

Hello,
I have developed a VBA Macro, which is correct with a small Project. But
when the project is longer, I have the message "The Method 'Tasks' of the
object '_IProjectDoc' failed" with the Error 2147417848. I don't know why.
Can you give me please a solution to solve this problem?
 
J

John

Nicole said:
Hello,
I have developed a VBA Macro, which is correct with a small Project. But
when the project is longer, I have the message "The Method 'Tasks' of the
object '_IProjectDoc' failed" with the Error 2147417848. I don't know why.
Can you give me please a solution to solve this problem?

Nicole,
I'm sorry but that error number doesn't mean anything to me - I'm sure
it means something but I don't have any idea what it is. If your macro
code isn't too involved can you post it, or at least the part of the
code where the failure occurred?

John
Project MVP
 
N

Nicole

Hello John,

I write a message with some code to explain where the problem is.
First I apply a filter and save the tasks’ID in a list. Then I make a list
with the predecessors of all this tasks. I delete all the tasks out of this
list and save this in a new project. We have so many loops.
Here is the code where the error appears:

'Boucle, qui parcourt toutes les tâches du planning actif
'En commençant par la fin du planning
For j = NbTasks To 1 Step -1

'On ne traite que les tâches non récapitulatives,
'car la suppression d'une tâche récapitulative entraine la suppression des
tâches subalternes
If ActiveProject.Tasks(j).Summary = False Then

'Initialisation du booléen OKPlan à faux
OKPlan = False

'Boucle, qui parcourt la liste des prédécesseurs mémorisés dans la matrice
ListPred, pour voir si la tâche y est inscrite
For k = 1 To Compteur

'Si l'ID de cette tâche j est dans la liste des prédécesseurs ListPred, le
booléen est mis à vrai
If (ActiveProject.Tasks(j).ID = ListPred(k)) Then
OKPlan = True
Exit For
End If
Next k
The mistake is on the line: “If (ActiveProject.Tasks(j).ID = ListPred(k))
Thenâ€
Thank you for your help.
 
J

John

Nicole said:
Hello John,

I write a message with some code to explain where the problem is.
First I apply a filter and save the tasks’ID in a list. Then I make a list
with the predecessors of all this tasks. I delete all the tasks out of this
list and save this in a new project. We have so many loops.
Here is the code where the error appears:

'Boucle, qui parcourt toutes les tâches du planning actif
'En commençant par la fin du planning
For j = NbTasks To 1 Step -1

'On ne traite que les tâches non récapitulatives,
'car la suppression d'une tâche récapitulative entraine la suppression des
tâches subalternes
If ActiveProject.Tasks(j).Summary = False Then

'Initialisation du booléen OKPlan à faux
OKPlan = False

'Boucle, qui parcourt la liste des prédécesseurs mémorisés dans la matrice
ListPred, pour voir si la tâche y est inscrite
For k = 1 To Compteur

'Si l'ID de cette tâche j est dans la liste des prédécesseurs ListPred, le
booléen est mis à vrai
If (ActiveProject.Tasks(j).ID = ListPred(k)) Then
OKPlan = True
Exit For
End If
Next k
The mistake is on the line: “If (ActiveProject.Tasks(j).ID = ListPred(k))
Thenâ€
Thank you for your help.
Nicole,
I know absolutely no French, so unfortunately I can't follow what you
are saying in your comment lines. Perhaps fellow MVPs, Jan DeMessmaeker
or Gerard Ducouret will jump in and help out if I can't.

I don't fully understand what you are trying to do. It almost sounds
like you are trying to create a new project file from an existing file
by first removing all predecessors. If that is the case there are much
easier ways to do that then to set up arrays for tasks and predecessors.

Nonetheless, in your opening description you mention that you delete
tasks out of the list. If that means that somewhere in your code, you
physically delete tasks from the file, then the ID sequence will change.
If you then try to compare task IDs to your ListPred array, the items
won't match up.

The most common reason why a statement that compares two arrays will
fail is that one or the other array index is out of range. In other
words, the code it trying to access an element of the array that doesn't
exist.

John
Project MVP
 

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