Create MS project file from excel
Hi,
Found the following code that enable to generate MS project file from excel,but I'm the Resource value.
Any help will be appriciated.
10X
See the following code:
Sub test()
Dim pjapp As Object
Dim strValue, strStartDate, strEndDate, Strresource As String
Dim newproj
Set pjapp = CreateObject("MSProject.application")
'this checks to see if a valid object has been created. If not it pops up
'a warning and then quits. Users without Project installed will see this message.
If pjapp Is Nothing Then
MsgBox "Project is not installed"
End
End If
'now that we have an application we make it visible
pjapp.Visible = True
'we add a new project
Set newproj = pjapp.Projects.Add
'Alternative: open existing MSProject file
'pjapp.Application.FileOpen "test_export.mpp"
'we set the title property (you can do whatever you want here.
newproj.Title = "My New Project"
'we make the new project the active project
Set ActiveProject = newproj
'and finally we add a new task to the project
'strValue = "yossi"
' strStartDate = "19/07/09"
' strEndDate = "28/07/09"
For I = 2 To 4
strValue = Worksheets("Sheet1").Range("A" & I)
strStartDate = Worksheets("Sheet1").Range("B" & I)
strEndDate = Worksheets("Sheet1").Range("C" & I)
Strresource = Worksheets("Sheet1").Range("D" & I)
newproj.Tasks.Add (strValue & " " & Strresource)
newproj.Tasks(I - 1).Start = strStartDate
newproj.Tasks(I - 1).Finish = strEndDate
' newproj.resource(I - 1).Name = Strresource (it's not working..)
Next I
' pjapp.FileSave
End Sub
As a matter of fact I have noticed.
that the command :
newproj.resources.Add.Name = Strresource
adds all the resources to the drop down list.
I nned that for each tasks there will be specific resource name.
Any ideas?
it works only from MS project...
It means that if I paste this code in MS project it works.,
But how can I use this code from the excel as part of the macro that I'm using to create the MS project file?
10X alot.