Work hours month by month

H

Hans

Hello

I am working with Project 2000 and I like to export resources working
hours month by month to Excel. I have

Jenny Carpenter
Bill Carpenter
Sean Plumber
Steve Plumber

and I like to have:

Jan Feb Mar April
Jenny 200 120 240 200
Bill 120 80 230 150
Sean and so on
Steve

Will this be possible to do?

I have tried to work with TimeScaleData, like

Dim R as Resource
Dim xlrng as Excel.range
Dim VM as TimeScalevalues
Dim MonthNumber As Integer

....

For each R in ActiveProject.Resources
If not (R is Nothing) then

'(Note: Projectstart is 10. januar 2005 and the project will finish
23. april 2005)
Set VM = R.TimeScaleData(Proj.ProjectStart, _
Proj.ProjectFinish, pjResourceTimescaledWork, _
pjTimescaleMonth, 1)

For MonthNumber = 1 to VM.Count
xlrng.Offset(0, MonthNumber) = VM(MonthNumber).Value
Next

End if
Next

Here is the problem that VM.Count only have the value 2 even the
project goes for 4 month, so it looks like:

Jan Feb Mar April
Jenny 200 660
Bill 120 460
Sean and so on
Steve

Any help?

Thanks
Hans
 
J

JackD

It seems like it should work.
Have you tried stepping through your code line by line?
Use the F8 key from the visual basic editor.

I'd try it but you need to post your complete code.
It does not appear there is an error in the parts that you have posted.
 
J

John

Dim R as Resource
Dim xlrng as Excel.range
Dim VM as TimeScalevalues
Dim MonthNumber As Integer

...

For each R in ActiveProject.Resources
If not (R is Nothing) then

'(Note: Projectstart is 10. januar 2005 and the project will finish
23. april 2005)
Set VM = R.TimeScaleData(Proj.ProjectStart, _
Proj.ProjectFinish, pjResourceTimescaledWork, _
pjTimescaleMonth, 1)

For MonthNumber = 1 to VM.Count
xlrng.Offset(0, MonthNumber) = VM(MonthNumber).Value
Next

End if
Next

Hans,
Your code was driving me nuts for awhile. Nothing "obviously" wrong but
like you said, it didn't work. However after a little troubleshooting I
found the problem. The TimescaleUnit constant should be:
pjTimescaleMonths
That little "s" on the end makes all the difference. I also assume you
set an object variable for "Proj" (i.e. Set Proj = ActiveProject).

Hope this helps.
John
 
J

JackD

Unlike you I wasn't going to try it out until I had the rest of the code.
Writing sub foo() and end sub are just too much trouble. :)
 
J

John

JackD said:
It seems like it should work.
Have you tried stepping through your code line by line?
Use the F8 key from the visual basic editor.

I'd try it but you need to post your complete code.
It does not appear there is an error in the parts that you have posted.

Jack,
I'm glad to see you didn't spot the error right away either.

John
P.S. I had to step through the code on a test file before the "duh" hit
me.
 

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