Excel data to MS Project throwing Error 1101

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
21,834
Office Version
  1. 365
  2. 2019
  3. 2013
  4. 2007
Platform
  1. 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
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
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Ok, Ok....I found the problem...:oops:
The test sheet started on row 2, as per the original code
which means the new tas will be i - 1...ergo Task 1
Code:
newproj.Tasks(i - 1).Start = strStartDate

However, the Real workbook had hidden rows which I failed to notice and starts on row 4 !!
Which means MSProject is trying to start the data at Task 3....which it can't do !

If anyone has viewed this, I appreciate you having a look.....a large trap for young players !!!
 
Upvote 0

Forum statistics

Threads
1,214,551
Messages
6,120,156
Members
448,948
Latest member
spamiki

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top