Error on Task object in Excel VBA : Object required

Copper Contributor

Error on Task object in Excel VBA : Object required

Hello I don't understand why the Task object gives me an error, maybe I should add a reference to the excel project, but I haven't found any suggestions online.
Please can someone help me?

Below I attach the Sub that gives me the error :

 

 

Sub SetOutline()
Dim TaskName As String
Dim Temp As Long
For Temp = 1 To ActiveProject.Tasks
 MsgBox "Task: " & ActiveProject.Tasks(Temp).Name & vbCrLf
Next
For Each t In ActiveProject.Tasks
    If Not t Is Nothing Then
        t.OutlineLevel = t.Text1
    End If
Next t
End Sub

 

 

Tanks a lot

Fabrizio

 

2 Replies

@FableoSanca 

The code that you posted is for Microsoft Project.

If you want to run it from Excel, you will have to create a Project.Application object and open or create a project object.

You cannot simply refer to ActiveProject in Excel VBA because ActiveProject is not an Excel object.

Ok Thanks a lot
Fabrizio