VBA Code to return WBS Field

S

Suzanne

Hi,

I'm still new to VBA so excuse my possibly simple question.

I am using a VBA code which returns Task information including Task ID
(TskID). The macro works well except for my purposes the Task ID is not a
good tracking / reference tool as it does not remain constant. Instead I
would like to return the Task WBS Code - can anyone please let me know what
code I would use?

Many Thanks,
Suzanne
 
R

Rod Gill

If you want a unique identifier that does not change as you insert and
delete tasks, use the Unique ID property. To read and use the Unique ID:

Dim UID as Long

UID=activeproject.tasks(1).UniqueID)

Activeproject.Tasks.UniqueID(UID)

To read the WBS (which also changes unless you manually over-write it):

ActiveProject.Tasks(1).WBS

--

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
 
S

Suzanne

Hi Rod,

Thanks for your reply. I've purchased and have just started reading your
book so I'm looking forward to this all making sense soon!

Unique ID is good but in this case we do really want the WBS. I have tried
ActiveProject.Tasks(1).WBS but receive a compile error Invalid use of
property.

Would this have something to do with the fact that the rest of the
information being sourced is from the ActiveSelection.Tasks (extract of
original code as follows)?

For Each t In ActiveSelection.Tasks
If Not t Is Nothing Then
TskID(i) = t.ID
TskNam(i) = t.Name
BStart(i) = t.BaselineStart
BFinish(i) = t.BaselineFinish
TskNot(i) = Replace(t.Notes, vbCr, vbLf)
i = i + 1

End If

Next t


I thought perhaps I needed another "For Each t in" directed to ActiveProject
which does not seem possible due to existing code. I also tried For Each t
In ActiveSelection.Tasks & ActiveProject.Tasks - it didn't like the &!

Thanks for your help.
Suzanne
 

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