Looking to Recover your Global.MPT? You’re in good company….

When working with Microsoft Project (MSP), there is nothing more frustrating than losing the hard work you’ve put into a file whether it’s a schedule or VBA / Macros to work with your schedule.

Today I’m here writing about ways to try to recover your Global.MPT because I completely lost it today…. or so I thought.  I was happily coding away building an awesome script in VBA  and was feeling such success when this setback had me going from blissful to horrified in seconds.  The code hung and I had to force MSP to close.  Once I tried to open it back again and go to my code, it was all gone!  The first thought that crossed my mind was, “Why didn’t I back it up?!?”  followed by, “How  could I have done such a rookie mistake?!?”

I then tried to calm down and try to troubleshoot and see if I had actually lost it all.   The thing is, I keep a backup of all my code that I push to production from the development environment. The code that I build as helper functions such as adding text to the beginning or the end of a group of tasks quickly, this code I keep it in my .MPT file because I don’t want to keep it in the development environment and accidentally push it to production.  I had built quite a few of this functions in the last couple of weeks, but hadn’t taken the time to back them up…. they are just little helper functions anyway, right?  Hard lesson to learn was how important they are to me once I realized they were all gone….

A quick search online does not quickly give you ways to try to restore your Global.MPT file.  I had to dig deep to actually find different methods to try.  I will add the two that might give you results.  Firstly, to find where in your computer you might find your Global.MPT,  you can check out this article from Microsoft Support.

Once I found my Global.MPT  on my computer at:

“C:/users/[your user name]/App data/Roaming/Microsoft/MS Project/1033”

I then immediately:

  1. Closed Microsoft Project completely
  2. Copied the Global.MPT file to a new folder
  3. Once I had a copy, I went back to the above address and renamade the file and changed the extension of the file to .MPP
  4. Then I opened the newly renamed file in step 3 with Microsoft Project
  5. The organizer pops up, then choose the Modules tab and copy all the “lost” modules to your new MPT file
  6. Make sure to reset any references in your library you were using for your macros if any

Of course, this doesn’t work for everyone.  If you are one of the unlucky ones, I have one more trick up my sleeve.  I found this solution when I was ready to give up on recuperating my awesome code.  I had already started to mourn the loss of such great work…

  1. Go to C:\Users\[Your User Name]\AppData\Local\Temp
  2. Filter by Date
  3. Scroll down until you find your latest, mine was: “AutoRecovery Save of Global (183).MPT
  4. I immediately made a copy before I attempted to open.
  5. Once I had the backup, I renamed the file and changed the extension to .MPP
  6. I opened it and the Organizer was immediately launched.
  7. I copied over my code from the Modules tab to my new file.

I cannot tell you the immense relief I felt once I figured I hadn’t lost it all.  I can recreate the few lines I did lose, but those helper functions are life (and time) savers for sure!

The moral of the story for both you and I is to make sure to create backups of ALL your code.  Even code that you might not think is very important.  It’s better to have it and not need it, than to need it and not have it.

Some ideas to save your code would be first of all NOT keep the code in Global.MPT.  Even if you do, make sure to save your code in an actual .MPP file and create backups of that.  Also, you can export your modules as .bas files or .frm for forms to a folder on your desktop.  I’ve actually created code that exports all of them quickly.  That’s one of the sub routines I had thought lost forever!  That would have been a shame to lose….

Anyway, good luck  recuperating your Global.MPT file…. know that you are in good company!


MS Project 2010 VBA: Uppercase or Lowercase

Today we are going to try our first VBA script on MAD Schedules!  I promise I’ll try to keep it as simple as possible so you can follow easily.  I assume you have the VBA Editor open and have a module ready for code.  If not, then go back to my post on How to Start with VBA in MS Project 2010.

Okay, let’s start!  I assume you have a schedule with some information.  Here is an example of a schedule I built:

I have a custom field in text1 called “Contract#”.  All the text in text1 is in lower case letters, but what if I want them to all be in upper case letters?  It would take me about 10 or 15 minutes to fix each one at a time… but what if I had 1000 lines?  That would take me quite some time!  Especially if I had different Contract numbers and couldn’t just fix it quickly.  That’s where the beauty of VBA comes in for our MS Project schedules!  I go to my VBA Editor with my blank module such as here:

In the editor you can type:

Sub UpperCase()
Dim tskTask As Task


For Each tskTask In ActiveProject.Tasks
tskTask.Text1 = UCase(tskTask.Text1)
Next tskTask


End Sub

This code can be used for any text field in Microsoft Project.  Just change out Text1 in the code for whatever field you need to change to Uppercase.

How to run your new VBA Script

Now you are wondering, how do I test this script?  First of all, make sure you are testing code on a copy of a schedule.  Do NOT test on a current file!  Once the changes are done with a script, there is NO undo button!  So proceed with caution…

There are a couple of ways you can access and use your new script.  I will touch on one way today.  Go to your project file and click on the Developer tab.  Then click on View Macros.

Make sure you are viewing macros only for your current project and choose Uppercase macro.  Then click on Run.

As you can see it worked!  My “project 001” text was all changed to “PROJECT 001”.

How to change to Lowercase Letters

To change your text to lowercase letters you add a new module to your VBA Editor.  If you try to use the same module as for the Uppercase script, there is potential for errors to be generated because I’m using the same variable for both scripts.

Type in the new module:

Sub LowerCase()
Dim tskTask As Task


For Each tskTask In ActiveProject.Tasks
tskTask.Text1 = LCase(tskTask.Text1)
Next tskTask


End Sub

To run it, go back to your project file Developer > View Macros > Lowercase > Run.  That should do it!

Now that you have a little practice with VBA Script, you can keep modifying this code to do other things in MS Project!


MS Project Formula: Custom Field for Checking Logic

A custom field that I use constantly when building project schedules is for checking if the task is missing either a predecessor or successor.  I call this field Logic, and I find it handy because the last thing you want on your hands is a project schedule with spaghetti logic.  The best practice for network logic is that every task has a predecessor or successor, except for the first task or the last task.  Of course, each project has it’s own quirks and you might find this doesn’t make sense.  That will have to be something you need to decide whether to not follow this, but make sure you clearly document it in your project plan assumptions.

Define Custom Field: Logic

The first thing to do is to create a custom field named Logic.  I will build it using Flag1.  

Step 1 – Highlight your first column by clicking on the title name of your column.

Step 2 – Right-click and choose Insert Column.

 Step 3 – Scroll down or start typing Flag1.  Choose Flag1.  Once the Flag1 column is in your Gantt Chart view highlight the whole column and right-click.

Step 4 – Rename Custom Field. Make sure you have Flag1 chosen.  Then click on Rename, change the name from flag1 to Logic, finally click OK.

Now we have created the field Logic.  Don’t close the Custom Fields menu yet.  Now we are going to build the formula to show us where we are mission a predecessor or successor (or both).  Then we will add a graphical indicator to quickly spot our missing logic.

Step 5 –  Click on the Formula button in the Custom Fields menu.  Type in the following formula in the Edit Formula box.

 

IIf(([Predecessors]="" Or [Successors]=""),True,False)

Here is the project image below

Don’t close your Custom Fields menu yet!  The last part is to put a graphical indicator (image).  It’s easier to spot this way instead of seeing yes and no all over the column.

Step 6 – Click on Graphical Indicators… button towards the bottom of the Custom Fields menu.  In the test for logic field type equals, in values enter True, and in image choose the image that you best like.  Then click OK, and OK again.  You are done.


If all is working correctly you should see where you might be missing logic on your Logic column shown with an image in each row that has missing logic.

That should do it!  You now can quickly see where you need predecessors or successors.  You can customize it into two different custom fields if you want to check one or the other.  Have fun building custom formulas!