« Microsoft Project Tip - Formulas and the IIF statement | Main | Formatting Task Links in MS Project »

How to open MS Project from Excel

I have a number of examples of exporting to Excel from MS Project (exporting task hierarchy and exporting monte carlo simulation data) but many people want to do just the opposite. They want to open a Project file from Excel. So here is a short example which shows opening the Project application from excel, creating a new file and adding a task.

The first thing that you need to do is to set a reference to the Microsoft Project Object Library. To do this go to 'the "Tools Menu" in the Visual Basic Editor (hit ALT+F11 to get there from Excel).


This should bring up a dialog box showing all of the available libraries. You will probably have to scroll down a bit to find the project library. Here you can see that I'm using Project 2002 as it is version 10.


Once you have set the reference the code is pretty simple:

Sub openMSProjectFromExcel()
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 If
'now that we have an application we make it visible
pjApp.Visible = True
'we add a new project
Set newProj = pjApp.Projects.Add
'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
newProj.Tasks.Add ("My First Task")
End Sub

Obviously you will want to do more where this leaves off, but it should be enough to get you started with using Project from Excel.


Comments (6)

manoj kumar d:

i do it this project

Project2Excel is an reporting and integration tool for Microsoft Project and Microsoft Excel. User defined templates provide users the ability to import/export data to/from Excel while retaining the hierarchical structure contained within Microsoft Project. This product provides an extended Excel formula language to support calculations based on the hierarchical structure of the project plan. VBA Source Code is included.

The product is only $29.95 and can be found at http://www.project2excel.com

Gelareh Mansouri:

dear sir
i need help for Microsoft Project Object Library
i need a refrence or text on this subject
i want access to my .mpp file data in excel please help me

ben phillips:

Works a treat, many thanks appreciate you posting the info sir

Crawford Young:

It is missing a carriage return inserted in the following line:

'we add a new project Set newProj = pjApp.Projects.Add

which will give the following new lines:

'we add a new project
Set newProj = pjApp.Projects.Add

Thanks for posting the code.
Good catch. I fixed it above. -Jack

Ahsan Abbas:

i want excel project

Post a comment

(Comments are moderated to fight SPAM and will be published after I have a chance to approve them. Thanks for waiting.)


The previous article is Microsoft Project Tip - Formulas and the IIF statement.

The next article is Formatting Task Links in MS Project.

Current articles are in the main index page and you can find a complete list of articles in the archives.

Creative Commons License
This weblog is licensed under a Creative Commons License.
Powered by
Movable Type 3.34