View Full Version : Looping Through NonContiguous Selections


Jim Aksel
06-19-2007, 11:54 PM
Project allows us to select up to 10 groups of non-adjacent tasks. I would
like to be able to loop through them programatically---

dim tsk as task
For each tsk in [The Block of non-Contiguos Selections]
'My wonderful code goes here
tsk.Text1="Wonderful Day"
Next tsk

Does anyone have a sample that would be useful?

Rod Gill
06-20-2007, 09:53 AM
Hi,

Try:

Sub test()
Dim Tsk As Task
For Each Tsk In Application.ActiveSelection.Tasks
Debug.Print Tsk.Name
Next Tsk
End Sub


--

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


----------------------------------------------------------------------------------------------------


"Jim Aksel" <JimAksel@discussions.microsoft.com> wrote in message
news:AC37498C-1448-4328-B348-C5EBC435B2C7@microsoft.com...
> Project allows us to select up to 10 groups of non-adjacent tasks. I
> would
> like to be able to loop through them programatically---
>
> dim tsk as task
> For each tsk in [The Block of non-Contiguos Selections]
> 'My wonderful code goes here
> tsk.Text1="Wonderful Day"
> Next tsk
>
> Does anyone have a sample that would be useful?

Jim Aksel
06-20-2007, 04:33 PM
Thanks. I need to look harder in the Object Browser next time around.
Works fine.
Jim
The software is not allowed to win.

"Rod Gill" wrote:

> Hi,
>
> Try:
>
> Sub test()
> Dim Tsk As Task
> For Each Tsk In Application.ActiveSelection.Tasks
> Debug.Print Tsk.Name
> Next Tsk
> End Sub
>
>
> --
>
> 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
>
>
> ----------------------------------------------------------------------------------------------------
>
>
> "Jim Aksel" <JimAksel@discussions.microsoft.com> wrote in message
> news:AC37498C-1448-4328-B348-C5EBC435B2C7@microsoft.com...
> > Project allows us to select up to 10 groups of non-adjacent tasks. I
> > would
> > like to be able to loop through them programatically---
> >
> > dim tsk as task
> > For each tsk in [The Block of non-Contiguos Selections]
> > 'My wonderful code goes here
> > tsk.Text1="Wonderful Day"
> > Next tsk
> >
> > Does anyone have a sample that would be useful?
>
>
>