Use VB to check Flag1 before Export

G

Guest

How do I check the value of the Flag1 field for each task
in a project?

I posted this question before, but got no responses. In
fact, I don't even see my original post. So, I apologize
if this is a duplicate.

The psudo-code I have so far is...

For Each tsk In ActiveProject.Tasks
If Not tsk Is Nothing Then
'check value of Flag1
'if value is "Yes" then export task to Excel
End If
Next tsk

Thanks

- Shawn
 
J

Jan De Messemaeker

Hi,

Consulting the Flag1 field is easy, it is called tsk.flag1 like you might
expect in OO programming.
So
If tsk.flag1 then

But you will have to define what you mean by "Export the task to Excel".
Is excel open at that point in time?
Which field of the task have to be copied, etc. etc.

The "Export" function which is in fact "Save As" takes a filter into account
so you could make your own filter based on Flag1 and Export, but that has
nothing to do with handling each tsk in VBA.
Hope this helps,

--
Jan De Messemaeker
Microsoft Project Most Valuable Professional
Project Management Consultancy
Prom+ade BVBA
32-495-300 620
 
T

Tomm

For Each tsk In ActiveProject.Tasks
If Not (tsk Is Nothing) Then
'check value of Flag1
If tsk.Flag1 then
'if value is "Yes" then export task to Excel
End If
End If
Next tsk
 
W

WD

You could use the filesaveas command along with a map and
filter -- example follows -- I find this to be the most
efficient approach given that maps and filters are simple
to set up and work with -- ie, you can set up all the
fields to export in the map/filter and won't have to worry
about that in the VBA code.

EXPORT TASK EXAMPLE CODE:

FileSaveAs Name:=filepath & filename,
FormatID:="MSProject.XLS5", map:="Map Name"
 

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