Runtime error '91'

Hi,

From a Cumulative project with 200+ project im getting a runtime error with following vba code:

Sub Macro1()
' Makro Macro1
Dim i As Integer
Dim subproj As MSProject.Subproject

    For Each subproj In ActiveProject.Subprojects
        i = i + 1
        MsgBox subproj.SourceProject.Name & " number " & i & " index " & subproj.Index
       
    Next

End Sub

Im getting following error at projectindex 25

Runtime Error '91'

Object variable or with block variable not set

What am i doing wrong? this only for testing, the goal is to print the subprojects with unfinished tasks

Regards

Torben

 

Answer
Answer

Toni,

A suggestion. Instead of using the MsgBox Function, try the following syntax,

Debug.Print sp.SourceProject.ProjectStart

Debug.Print sp.SourceProject.ProjectFinish

That will save a lot of hitting the "OK" button each time the message pops up. To view the results with this modification, go to View/Immediate Window.

Just curious, did your test with 39 subprojects include the 25th subproject?

John

1 person found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated September 30, 2021 Views 1,801 Applies to: