Reading MS Project file using PIA

X

xmf36d

I have a MSProject (*.mpp) file which i read using a vb.net application i
have made (via the Primary Interop Assembly)
I manage to read the tasks but how do i get the Usage Details of a task, ie
work (date and hours)?
 
X

xmf36d

Thanks for the answer, it helped me in the right direction, here is my code:

If appclass.FileOpenEx(Projectfile, False, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, _
PjPoolOpen.pjPoolReadWrite, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing) Then
For Each currTask As Task In appclass.ActiveProject.Tasks
tsvs = currTask.TimeScaleData(currTask.Start,
currTask.Finish, 0, 5, 1)
For Each tsv In tsvs
ListBox2.Items.Add(currTask.Name & " - " & currTask.Work
& " - " & tsv.Value)
Next tsv
Next
End If

tsv.Value gives an error, An unexpected error occurred with the method.

Grateful for any help!
 
J

Jan De Messemaeker

I cannnot reproduce the error.
Try with one task. does it work?

--
Jan De Messemaeker
Microsoft Project Most Valuable Professional
+32 495 300 620
For availability check:
http://users.online.be/prom-ade/Calendar.pdf
xmf36d said:
Thanks for the answer, it helped me in the right direction, here is my
code:
If appclass.FileOpenEx(Projectfile, False, Type.Missing,
 
X

xmf36d

Sometimes it runs true 3-4 times and then returns the error message, but
mostly I get the error on the first run.

Found a comment on the internet:
'This is a bug in Microsoft Project which prevents holding references to a
certain number of TimeScaleValue objects, and you will get the same
0x800a03ec error in C# or VB.NET client when retrieving the Value property
of TimeScaleValue object in a loop which iterates more than 10 times. The
garbage collector of .NET or Java is not clearing up the references fast
enough.

I solved the problem by adding
System.GC.Collect()
For Each tsv In tsvs
If CStr(tsv.Value) <> "" Then
ListBox2.Items.Add(currTask.Name & " - " &
currTask.Work & " - " & tsv.Value)
End If
System.GC.Collect()
Next tsv

Not a smart solution, but it works.

Thanks
 

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