|
-
Jul 12th, 2005, 02:15 PM
#1
Thread Starter
New Member
[Resolved]MS Project VBA, the red-headed stepchild
I'm writing code that takes cell strings in Excel and attempts to match them with resource codes in MS Project. It's a pain and there is very little information I could find that helps. If anyone could give me a link of a forum that deals with MS Project I would really appreciate it. Here's a sample of my chicken scratch play code just to get anything to populate.
VB Code:
Dim ObjTask As String, SourceTask As Task
Dim appXL As Excel.Application
Dim R As Long, Names As String
Dim hours As Double
Dim N As Long
Rws = 3
Sheets("Summary Hrs").Select
While Rws < 650
TaskName = Cells(Rws, "B").Text
If TaskName <> "" Then
WindowActivate WindowName:="C:\Documents and Settings\me\Desktop\project_template.Published.mpp"
SelectTaskField Row:=1, Column:="Name", RowRelative:=False
For R = 1 To ActiveProject.Tasks.Count
ObjTask = ActiveProject.Tasks(R).Name
If ObjTask = TaskName Then
Sheets("Summary Hrs").Select
Rws2 = Rws + 1
While Cells(Rws2, "C").Text <> ""
rescode = Cells(Rws2, "C").Text
hours = Cells(Rws2, "E").Text
Names = rescode & ", " & Names
Names = Left$(Names, Len(Names) - Len(ListSeparator & " "))
Rws2 = Rws2 + 1
Wend
SetTaskField Field:="Resource Names", Value:=Names, AllSelectedTasks:=True
R = ActiveProject.Tasks.Count
'WindowActivate WindowName:="C:\Documents and Settings\me\Desktop\project_template.Published.mpp"
'SelectTaskField Row:=R, Column:="Name", RowRelative:=False
'SetTaskField Field:="Resource Names", Value:=AllResources, AllSelectedTasks:=True
'ResourceAssignment Resources:=rescode, Operation:=pjAssign
'WindowActivate TopPane:=False
'SetTaskField Field:="Work", Value:=hours, TaskID:=R, ProjectName:="C:\Documents and Settings\me\Desktop\project_template.Published.mpp"
End If
Next R
End If
Rws = Rws + 1
Wend
End Sub
I tried it a few ways. Just dumping all the gathered resource codes puts them in the first line my my project only. I'm sure it's just a simple error, it was working better earlier. After 8 hours of this, it's hard to keep starit what you've changed in your code and what made it break last.
Any advice will help.
Thanks,
B
Last edited by queenb2005; Jul 18th, 2005 at 06:59 AM.
Reason: Resolved
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|