I work with Microsoft Project 2013. At my request to write a macro, the “friend” answered me with the following procedure:

Sub Macro1() n = InputBox("Input Name of the New task") a = CInt(InputBox("Input duration of subtask a")) b = CInt(InputBox("Input duration of subtask b")) Set oTask = ActiveProject.Tasks.Add(n) Application.SetTaskField "Number1", a, , , oTask.ID Application.SetTaskField "Number2", b, , , oTask.ID Application.SetTaskField "Duration", oTask.Number1 + oTask.Number2, , , oTask.ID End Sub 

However, when I try to process this procedure step by step using the F8 key, my Project “stumbles” on the penultimate line, namely:

 Application.SetTaskField "Duration", oTask.Number1 + oTask.Number2, , , oTask.ID 

And the error pops up:

Run-time error "1004": unexpected method error.

But at this stage, the question is not even why this error pops up.
Please help test this procedure on your installed version of Project. Because a comrade swears that everything happens on his computer "without a hitch."

Perhaps an error with my project?

    0