Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
other
informationbridge
office.intranets
office.misc
office.setup
office.xml
officeupdate
onenote
photodraw.discussion
powerpoint
producer
proj.standard&server
project
project.developer
project.pro_and_serve
project.server
project.vba
project2000
publisher
publisher.prepress
publisher.programming
publisher.webdesign
visio
visio.createshapes
visio.database.modeling
visio.dev.diagrams
visio.dev.shapesheet
visio.dev.vba
visio.dev.vc
visio.developer
visio.general
visio.installation
visio.printing
visio.software.modeling
visio.troubleshoot
  
 
date: Fri, 3 Oct 2008 13:39:01 -0700,    group: microsoft.public.project.developer        back       


Sort versus order tasks are looped over   
I've got a bit of code that sorts tasks based on Text1, then it loops over 
the tasks looking at all the Text1 fields.  After I run the macro I can 
examine the schedule and the sort looks correct, everything in alphabetical 
order.  But when I loop over the tasks, the Text1 values I get are not 
alphabetical (looks like they're in ID order).  How do I iterate over all 
tasks in Text1 order?

    -- Carl
date: Fri, 3 Oct 2008 13:39:01 -0700   author:   Carl

RE: Sort versus order tasks are looped over   
Here's my code:

Sub SortedTaskLoop()
  Dim Tsk As Task
  ActiveProject.Tasks.Application.Sort Key1:="Text1", Renumber:=False, 
Outline:=False
  For Each Tsk In ActiveProject.Tasks
    If Not Tsk Is Nothing Then ' test for blank rows
      Debug.Print Tsk.ID; Tsk.Text1
    End If
  Next Tsk
End Sub

    -- Carl

"Carl" wrote:

> I've got a bit of code that sorts tasks based on Text1, then it loops over 
> the tasks looking at all the Text1 fields.  After I run the macro I can 
> examine the schedule and the sort looks correct, everything in alphabetical 
> order.  But when I loop over the tasks, the Text1 values I get are not 
> alphabetical (looks like they're in ID order).  How do I iterate over all 
> tasks in Text1 order?
> 
>     -- Carl
date: Fri, 3 Oct 2008 14:01:01 -0700   author:   Carl

Re: Sort versus order tasks are looped over   
Jack,

Thanks for the suggestion, switching to SelectAll and ActiveSelection did 
the trick!

    -- Carl

"Jack Dahlgren MVP" wrote:

> I'd probably build an array or list of tasks, sort it, then loop through it.
> Or you might see what happens if after you sort - you could then do a 
> SelectAll then loop through the activeselection.tasks
> 
> -Jack Dahlgren
> 
> "Carl"  wrote in message 
> news:BC792A77-B3A9-4386-969F-7EEBF9DC5059@microsoft.com...
> > Here's my code:
> >
> > Sub SortedTaskLoop()
> >  Dim Tsk As Task
> >  ActiveProject.Tasks.Application.Sort Key1:="Text1", Renumber:=False,
> > Outline:=False
> >  For Each Tsk In ActiveProject.Tasks
> >    If Not Tsk Is Nothing Then ' test for blank rows
> >      Debug.Print Tsk.ID; Tsk.Text1
> >    End If
> >  Next Tsk
> > End Sub
> >
> >    -- Carl
> >
> > "Carl" wrote:
> >
> >> I've got a bit of code that sorts tasks based on Text1, then it loops 
> >> over
> >> the tasks looking at all the Text1 fields.  After I run the macro I can
> >> examine the schedule and the sort looks correct, everything in 
> >> alphabetical
> >> order.  But when I loop over the tasks, the Text1 values I get are not
> >> alphabetical (looks like they're in ID order).  How do I iterate over all
> >> tasks in Text1 order?
> >>
> >>     -- Carl 
>
date: Fri, 3 Oct 2008 19:09:00 -0700   author:   Carl

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us