Deleting the content the a field by background processing

  • Thread starter יו×ב שוחט
  • Start date
×

יו×ב שוחט

Hi,
I Wanted to know how can i delete the contect of a specific field by
background processing.
I know how to do it with foreground processing:
SelectTaskColumn Column:="Enterprise Flag2"
OutlineShowAllTasks
EditClear Contents:=True, Formats:=True, Notes:=True, Hyperlinks:=True

the problem is that I don't want "Enterprise Flag2" to be visible in current
view (and I don't want to use another view).

Thanks,
Yoav
 
J

John

ȇ·†˘ÂÃË said:
Hi,
I Wanted to know how can i delete the contect of a specific field by
background processing.
I know how to do it with foreground processing:
SelectTaskColumn Column:="Enterprise Flag2"
OutlineShowAllTasks
EditClear Contents:=True, Formats:=True, Notes:=True, Hyperlinks:=True

the problem is that I don't want "Enterprise Flag2" to be visible in current
view (and I don't want to use another view).

Thanks,
Yoav

Yoav,
If you want to clear a field totally in the background, this is your
best option:
Sub clearfield()
For Each t In ActiveProject.Tasks
If Not t Is Nothing Then
t.EnterpriseFlag2 = False
End If
Next t
End Sub

Hope this helps.
John
Project MVP
 
×

יו×ב שוחט

Thanks, it work!
What is the consequences of using this method when there are 100,000 tasks?
Does it have efficiency issues?
 
×

יו×ב שוחט

Hi,
Another question - This code doesn't work when no project is open. How can I
check if a project is opened/closed?
 
J

Jan De Messemaeker

Hi,

Suppose "thepr" is the name of the project:

pjfound=false
For each pj in projects
if pj.name="thepr" then
pjfound=true
pj.activate
end if
next pj

HTH
 
J

John

ȇ·†˘ÂÃË said:
Hi,
Another question - This code doesn't work when no project is open. How can I
check if a project is opened/closed?

Yoav,
Yeah, you're right, it doesn't. I assumed you were working with an
active project. I think Jan answered the second part but as an
alternative, here is a sequence of code I use on several of my macros:
On Error Resume Next
TempStr = ActiveProject.Name
If Err > 0 Then
MsgBox "There is no open project." & Chr(13) & _
"Please open a project and run again.", vbCritical, "COBRA
Export - Fatal Errror"
On Error GoTo 0
End
End If
If ActiveProject.Tasks.Count = 0 Then
MsgBox "There are no tasks in this file." & Chr(13) & _
"Please open a populated file and run again.", vbCritical,
"COBRA Export - Fatal Error"
End
End If

John
 
J

John

ȇ·†˘ÂÃË said:
Thanks, it work!
What is the consequences of using this method when there are 100,000 tasks?
Does it have efficiency issues?

Yoav,
For very large files, it may take several seconds to loop through all
tasks to clear or set a field. Sometimes I use an alternate method (all
done in VBA). Note: this technique only works for enterprise fields if
you are working in an enterprise environment.
1. Temporarily add the desired column to a view. It could simply be a
temporary custom view with only the ID and desired column.
2. Create and apply a filter looking for the data to be cleared/set.
Obviously if the filter yields nothing, the code doesn't need to go any
further.
3. Select all tasks of the active filter view and run a clearing/setting
loop on just those tasks, or, use EditDelete on the selected set.
4. Delete the filter and remove the column from the view.

Of course if the filter yields all tasks, then this shortcut doesn't
reduce the loop run time.

Hope this helps.
John
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