Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export with VBA from Excel to MSProject

Status
Not open for further replies.

nkamp

Programmer
Jan 19, 2004
35
0
0
NL
Hello,

I have to export data (date's, description) from a excel file to a MSProject file. Oke, I can understand that I can open a MSproject file. But then: how do you paste certain cell data from excel into the MSProject cells?

Does somebody have a example

Thanks in advance,

Nico
 
Allright, I have already solved by my self. So If anybody need support about this subject I can help him or her

Nico
 



You might just post your solution. That is the acceptable closure.

Skip,
[sub]
[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue][/sub]
 
Hello,

You can look at Here I have the code which I'm using and is working. My solution beneath is straight forward and simple.

Code:
Sub openMSProjectFromExcel()
Dim pjapp As Object
Dim strValue, strStartDate, strEndDate 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 = Worksheets("Blad1").Range("A2")
    strStartDate = Worksheets("Blad1").Range("B2")
    strEndDate = Worksheets("Blad1").Range("C2")
    newproj.tasks.Add (strValue)
    newproj.tasks(1).Start = strStartDate
    newproj.tasks(1).Finish = strEndDate

    pjapp.FileSave
End Sub
[code]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top