Results 1 to 5 of 5

Thread: [Resolved]MS Project VBA, the red-headed stepchild

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2005
    Location
    Florida
    Posts
    12

    Resolved [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:
    1. Dim ObjTask As String, SourceTask As Task
    2. Dim appXL As Excel.Application
    3. Dim R As Long, Names As String
    4. Dim hours As Double
    5. Dim N As Long
    6. Rws = 3
    7. Sheets("Summary Hrs").Select
    8. While Rws < 650
    9. TaskName = Cells(Rws, "B").Text
    10. If TaskName <> "" Then
    11. WindowActivate WindowName:="C:\Documents and Settings\me\Desktop\project_template.Published.mpp"
    12.  
    13. SelectTaskField Row:=1, Column:="Name", RowRelative:=False
    14. For R = 1 To ActiveProject.Tasks.Count
    15.  
    16.     ObjTask = ActiveProject.Tasks(R).Name
    17.     If ObjTask = TaskName Then
    18.         Sheets("Summary Hrs").Select
    19.         Rws2 = Rws + 1
    20.         While Cells(Rws2, "C").Text <> ""
    21.             rescode = Cells(Rws2, "C").Text
    22.             hours = Cells(Rws2, "E").Text
    23.             Names = rescode & ", " & Names
    24.             Names = Left$(Names, Len(Names) - Len(ListSeparator & " "))
    25.             Rws2 = Rws2 + 1
    26.         Wend
    27.         SetTaskField Field:="Resource Names", Value:=Names, AllSelectedTasks:=True
    28.         R = ActiveProject.Tasks.Count
    29.         'WindowActivate WindowName:="C:\Documents and Settings\me\Desktop\project_template.Published.mpp"
    30.             'SelectTaskField Row:=R, Column:="Name", RowRelative:=False
    31.             'SetTaskField Field:="Resource Names", Value:=AllResources, AllSelectedTasks:=True
    32.             'ResourceAssignment Resources:=rescode, Operation:=pjAssign
    33.             'WindowActivate TopPane:=False
    34.             'SetTaskField Field:="Work", Value:=hours, TaskID:=R, ProjectName:="C:\Documents and Settings\me\Desktop\project_template.Published.mpp"
    35.     End If
    36. Next R
    37. End If
    38. Rws = Rws + 1
    39. Wend
    40. 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
  •  



Click Here to Expand Forum to Full Width