way to test if task exists?

T

theintern

I'm looking for a way to see if any tasks remain once a filter is applied.
if there are tasks, i need to edit their constraints. if not, just keep
going through the code (ideally it would create a picture saying "no tasks
for this resource" but i realize that's probably not realistic.) The
annoyance lies in that if there are no tasks and it tries to edit them, it
ends up inserting an extra row. here are the lines of code. the extra row
gets inserted after the "SetTaskField Field" command. Once i go back to
"AllActive" there is now a new black row (a task). Anybody know how to get
around this, besides filtering out all the blank tasks?

'Backfeeds unassigned tasks
FilterApply Name:="Yes"
SelectAll
SetTaskField Field:="Constraint Type", Value:="As Late As Possible",
AllSelectedTasks:=True
FilterApply Name:="All Active"

thanks!
scott
 
J

Jack Dahlgren

Scott,

You are going about this the wrong way.
What does your filter test for?
Let me give you an example.
Assume that the filter tests for tasks which have no resources assigned.

the code would be

sub theintern()
dim t as task
dim ts as tasks
set ts = activeproject.tasks
for each t in ts
if not t is nothing then
if not t.summary then
if t.resources = "" then
t.contstrainttype = pjALAP
end if
end if
end if
next t
end sub

Working with selections and fields the way you are doing is not very
effective. You can see the problems you have run into.
The above code works in the background no matter which view or filter is
applied.

I suggest you read through the articles on working with tasks that I have
here:
http://zo-d.com/blog/archives/programming.html

-Jack Dahlgren
 
T

theintern

The filter is for all tasks with a "Yes" in the resource initials column,
meaning that no resource has yet been assigned to them. i need to filter for
these tasks, then change their constraint types to "As Late As Possible."
But if there are no tasks with "Yes" in the resource initials, it ends up
inserting a blank task. I'll read that link you sent and see if that helps
at all. If what I've said here changes/clarifies anything, let me know.

Thanks
scott
 
M

Mike Glen

Hi ,

Next time, try posting on the microsoft.public.project.developer newsgroup.
Please see FAQ Item: 24. Project Newsgroups. FAQs, companion products and
other useful Project information can be seen at this web address:
http://project.mvps.org/faqs.htm

Mike Glen
Project MVP
 

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