Michael M
Well-known Member
- Joined
- Oct 27, 2005
- Messages
- 21,835
- Office Version
- 365
- 2019
- 2013
- 2007
- Platform
- Windows
Guys
I have some code written by xld, to create a MSProject file and populate the tasks and dates ....
I know I'm doing this the wrong way 'round, (it should be in Project and importing), but my peers want it in Excel.
I tested it on a small sample of data and it worked fine....Now I'm in the real workbook it fails.
I'm Getting a Runtime error 1101 on the line in red.
The dates are formatted as dates, and I have tried dimming them as dates or strings.
IS there anyone that can shed a little light on this....
Any feedback would be appreciated
I have some code written by xld, to create a MSProject file and populate the tasks and dates ....
I know I'm doing this the wrong way 'round, (it should be in Project and importing), but my peers want it in Excel.
I tested it on a small sample of data and it worked fine....Now I'm in the real workbook it fails.
I'm Getting a Runtime error 1101 on the line in red.
The dates are formatted as dates, and I have tried dimming them as dates or strings.
IS there anyone that can shed a little light on this....
Any feedback would be appreciated
Rich (BB code):
Sub MM1()
Dim pjapp As Object
Dim strValue As String, strStartDate As String, strEndDate As String, Strresource As String
Dim newproj
Set pjapp = CreateObject("MSProject.Application")
If pjapp Is Nothing Then
MsgBox "Project is not installed"
Exit Sub
End If
pjapp.Visible = True
Set newproj = pjapp.Projects.Add
newproj.Title = "My New Project"
Set ActiveProject = newproj
For i = 6 To 45
strValue = Worksheets("Report").Range("AF" & i)
strStartDate = Worksheets("Report").Range("AU" & i)
strEndDate = Worksheets("Report").Range("AV" & i)
Strresource = Worksheets("Report").Range("AF" & i)
newproj.Tasks.Add (strValue & " " & Strresource)
newproj.Tasks(i - 1).Start = strStartDate
newproj.Tasks(i - 1).Finish = strEndDate
If Not ExistsInCollection(newproj.Resources, Strresource) Then _
newproj.Resources.Add.Name = Strresource
newproj.Tasks(i - 1).ResourceNames = Strresource
Next i
End Sub