Importing Files to Project Online with VBA

In yesterday’s post, I talked about how to run a script to export all of our Microsoft Project schedules into XML files.  In this post, I’ll provide the script to import these into a new instance of Project Server – either on-prem or online.  Note that this script will not import custom fields – but could be easily adapted to capture and transfer custom fields.

Note also that there are other third party tools that do much of the same thing, but better.

Caveats aside, if you followed yesterday’s post, you should now have a directory called C:\Exports that contains all of the exported project schedules in an XML format.

image

You should also have a Microsoft Project schedule containing a list of all of the projects you wish to import.

image

Add the following code…

Sub ImportProjects()

    Dim T As Task
    Dim fName As String

    For Each T In ActiveProject.Tasks
        fName = T.Name
        Application.FileOpenEx Name:="C:\Exports\" & fName & ".mpp", ReadOnly:=False, FormatID:="MSProject.MPP"
        Application.FileSaveAs Name:="<>\" & fName, FormatID:=""
        Application.FileCloseEx pjSave, True, False
    Next T

End Sub

…and run to import the files.  You will probably need to click through the prompts as they appear.

Pair this with a utility to publish all of the projects like the one Alex Burton wrote here and you’ve now moved your projects from one environment to another.

Advertisements
Importing Files to Project Online with VBA

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s