ActiveSelection.Tasks(1) fails with late binding

J

Jim Zeeb

I'm trying to change my code to use Late Binding of MsProject.

The MsProject application object I'm using is called msp

After I've done a msp.Find that was successful, I'm trying to set a task
object to the task that was found by using:
Set tsk = msp.ActiveSelection.Tasks(1)

This is failing with Object not found.

msp.ActiveSelection.Tasks.Count returns 1
If I include a reference to MsProject, then "Set tsk =
ActiveSelection.Tasks(1)" works OK.
I've verified in the UI that the task being found is not a blank row.

What's happening here?

Jim Zeeb
 
R

Rod Gill

Hi Jim,

I haven't experienced that problem, but I have just reproduced it. The
following does work though:

Sub test()
Dim prj As Object
Dim T As Object
Set prj = GetObject(, "MSProject.Application")
For Each T In prj.ActiveSelection.Tasks
Debug.Print T.Name
Next T
Set prj = Nothing
End Sub
 

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