Recently I’ve been playing around on how to open a Microsoft Project file using Excel with VBA. This script should work at minimum for current versions of Microsoft Project. If you need it for an earlier version, it should be similar, so play around with the code.
Project Viewer 365 allows project team members to open MS Project MPP Plans from cloud locations like Google Drive. Dropbox, OneDrive, SharePoint Online, Box, Basecamp, URL Links and email attachments. Project Viewer 365 is compatible with Microsoft Project (MPP file format) 2016, 2013, 2010, 2007, 2003 and earlier versions. Open any Microsoft Project MPP file from your device, network, intranet or cloud location. Download Project Plan 365 Open any Microsoft Project file from your device, network, intranet or cloud location. Open your Microsoft Project file in your.
Start in Excel with VBA
You can build a procedure Sub in your VBA Editor after you add a new Module to your current workbook.
Before starting to write your code, make sure you have the right references to access Microsoft Project! Click on Tools>References>Microsoft Project xx.x Object Library. Then click okay.
Ready to Access Microsoft Project from Excel
Now you are ready to start coding in Excel to access information from Microsoft Project. Let’s start by opening a Microsoft Project file from Excel.
Make sure to first set up your variables, which in this script you only need one. You will need one variable for your MS Project application, which I called projApp.
Using Error Handling
I use the On Error Resume next in case MS Project is not installed and an error occurs. This way the code stops running and you don’t get an error. We set projApp to be a new instance of the object type. This means we can now access everything we need in MS Project.
NOTE: Every time you run a new Macro / VBA script you run a risk of losing all your work. When trying out new code I recommend you use it on copies of your projects and not on active projects. This way if your VBA doesn’t run correctly, you won’t lose valuable information. Run it at your own risk!
Where you see “C:<>My Example Project.mpp”, this is where you put the information on where YOUR file is located. I took out most of my file path to not make it confusing
Of course, this is just the staring code where it just opens the Microsoft Project, you will need to write more code to do what you want it to do.
The last comment I want to make is that about the project file you might be trying to open. I have found that if your project file has macros, then you might have trouble using this macro because of Microsoft built in security. You might have to change the security settings so that your macro can work.
Otherwise, it works like a charm!
If you want to learn how to start with VBA, check out one of my posts on looping through tasks using the For Each…Next loop.
Learn Microsoft Project VBA
VBA editor using the View tab or the Developer tab
Navigate the VBA Editor
Open Microsoft Project File Online
- Object Browser window
- Project Explorer window
- Toolbars
- Standard toolbar
- Edit toolbar
- Debug toolbar
- UserForm toolbar
- Custom toolbar
Open Microsoft Project File Viewer
Use Option Explicit
Use the message box (MsgBox) function
Open Microsoft Project File In Excel
Change the text of all tasks to all lowercase or all uppercase
Open Microsoft Project File
Loop through tasks and resources using for each....next loops
How To Open Microsoft Project File
Manually export VBA modules