Object variable or With block variable not set

T

tpiers

I have two projects. When I run the following from one project I get the
expected results. When I activate the other project and run it, I get the
error message 'Object variable or With block variable not set. I cannot
figure it out.

Sub Test()
For Each T In ActiveProject.Tasks
Debug.Print T.Name
Next T
End Sub

I do not know if it makes a difference, but the project where the code works
was never published on PWA. The other project was published, but then saved
locally. I am running the VBA against both projects stored locally.

I am using Project Professional 2002.

Any hints would be appreciated.

Thanks, Tom
 
T

tpiers

That was the problem. Thanks Rod. Tom

Rod Gill said:
Does the other project have any blank lines? For safety always use:

Sub Test()
For Each T In ActiveProject.Tasks
If Not T is Nothing Then
Debug.Print T.Name
End If
Next T
End Sub

This ignores blank rows.
--

Rod Gill
Project MVP

Project VBA Book, for details visit:
http://www.projectvbabook.com

NEW!! Web based VBA training course delivered by me. For details visit:
http://projectservertraining.com/learning/index.aspx
 
Top