VBA Macro Code Error (Gerard)

V

Verossa

Hi All

I have tried to input Gerards macro for exporting resource by project into MS Excel and am recieving the following error:

Run-time error '91':
Object variable or With block variable not set

When I debug the error it highlights the following line:

If oTache.Parent = "Microsoft Project" Then

Is there something unique in my local setup that is causing this error?

TIA to anyone who can help - Vers

Here's the code Gerard forwarded:


Sub Tache_Projet()
Dim oTache As Object, NomProj As String

For Each oTache In ActiveProject.Tasks
If Not oTache Is Nothing Then
oTache.Text10 = oTache.Name 'Copie de sécurité...
If oTache.Flag1 = False Then 'pour ne pas insérer le nom 2 fois
If oTache.Parent = "Microsoft Project" Then
NomProj = oTache.Name
GoTo Suite
End If
If oTache.Parent.Parent = "Microsoft Project" Then
NomProj = Left(oTache.Parent.Name, Len(oTache.Parent.Name) - 4)
GoTo Suite
End If
If oTache.Parent.Parent.Parent = "Microsoft Project" Then
NomProj = Left(oTache.Parent.Parent.Name, Len(oTache.Parent.Parent.Name) - 4)
GoTo Suite
End If
Suite:
oTache.Name = NomProj & " " & oTache.Name
oTache.Flag1 = True
End If
End If
Next

End Sub
 
G

Gérard Ducouret

Hello Verossa,

I can't reproduce the bug, but I didn't had time and elements to made
exhaustive tests. Could you send me your mpp file (Zipped)

Gérard Ducouret



Verossa said:
Hi All

I have tried to input Gerards macro for exporting resource by project into
MS Excel and am recieving the following error:
Run-time error '91':
Object variable or With block variable not set

When I debug the error it highlights the following line:

If oTache.Parent = "Microsoft Project" Then

Is there something unique in my local setup that is causing this error?

TIA to anyone who can help - Vers

Here's the code Gerard forwarded:


Sub Tache_Projet()
Dim oTache As Object, NomProj As String

For Each oTache In ActiveProject.Tasks
If Not oTache Is Nothing Then
oTache.Text10 = oTache.Name 'Copie de sécurité...
If oTache.Flag1 = False Then 'pour ne pas insérer le nom 2 fois
If oTache.Parent = "Microsoft Project" Then
NomProj = oTache.Name
GoTo Suite
End If
If oTache.Parent.Parent = "Microsoft Project" Then
NomProj = Left(oTache.Parent.Name, Len(oTache.Parent.Name) - 4)
GoTo Suite
End If
If oTache.Parent.Parent.Parent = "Microsoft Project" Then
NomProj = Left(oTache.Parent.Parent.Name,
Len(oTache.Parent.Parent.Name) - 4)
 
M

Mark Durrenberger

You test on "nothing" tasks, what about "summary" or "external"

--
_________________________________________________________
Mark Durrenberger, PMP
Principal, Oak Associates, Inc, www.oakinc.com
"Advancing the Theory and Practice of Project Management"
________________________________________________________

The nicest thing about NOT planning is that failure
comes as a complete surprise and is not preceded by
a period of worry and depression.

- Sir John Harvey-Jones
Verossa said:
Hi All

I have tried to input Gerards macro for exporting resource by project into
MS Excel and am recieving the following error:
Run-time error '91':
Object variable or With block variable not set

When I debug the error it highlights the following line:

If oTache.Parent = "Microsoft Project" Then

Is there something unique in my local setup that is causing this error?

TIA to anyone who can help - Vers

Here's the code Gerard forwarded:


Sub Tache_Projet()
Dim oTache As Object, NomProj As String

For Each oTache In ActiveProject.Tasks
If Not oTache Is Nothing Then
oTache.Text10 = oTache.Name 'Copie de sécurité...
If oTache.Flag1 = False Then 'pour ne pas insérer le nom 2 fois
If oTache.Parent = "Microsoft Project" Then
NomProj = oTache.Name
GoTo Suite
End If
If oTache.Parent.Parent = "Microsoft Project" Then
NomProj = Left(oTache.Parent.Name, Len(oTache.Parent.Name) - 4)
GoTo Suite
End If
If oTache.Parent.Parent.Parent = "Microsoft Project" Then
NomProj = Left(oTache.Parent.Parent.Name,
Len(oTache.Parent.Parent.Name) - 4)
 

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