Automating MS Project

hatman

Well-known Member
Joined
Apr 8, 2005
Messages
2,664
I am trying to retrieve a list of Tasks from an MS Project File. The nuts and bolts of the effort are pretty straightforward. I'm having problems with closing the file(s) when I'm done. Here is the important parts of my routine:

Code:
...
Set Mpp = New MSProject.Application
...
Mpp.FileOpenEx Name:="G:\ACE\Lab Status Monitors\Sandbox\Template Folder\MasterC.mpp", ReadOnly:=True, openpool:=pjPoolReadOnly
...
Mpp.Quit
Set Mpp = Nothing
...

The actual source file is nothing but a reference to 25 OTHER mpp files, each of which references still other files. In Parsing the project.tasks collection, there are over 9500 tasks, as it recursively pulls tasks from each subfile in the tree. This all works flawlessly if slowly. Untill I get to Mpp.Quit. At that point, my heretofor invisible Project application becomes visible with the SaveAs user dialog displayed. This is IN SPITE of setting Mpp.DisplayAlerts = False. I also found that unlike Excel, where I can set the .Saved property to true, in Project that's a Readonly property. And while the Project menu offers the Close command for each individual project object, there is NO .Close mehod available through the Object Model interface. Anybody have any advice? I'm getting very frustrated on this one.
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
It has been a very long time since I used Project, but isn't there a FileClose method? IIRC it also (much like the Close in Excel) allows you to specify you don't want to save.
 
Upvote 0
It has been a very long time since I used Project, but isn't there a FileClose method? IIRC it also (much like the Close in Excel) allows you to specify you don't want to save.

SWEET! I should have been clued in with the FileOpenEX syntax. There are (2) methods under the Application object: FileCloseEX and FileCloseAllEX, and yes there is an enumerated argument to specify the SaveAs prompt display. Silly me, I was looking for this under the .Project object.

Thanx Rory! As ever, A lifesaver!
 
Upvote 0
Hello guys, i'm working on getting data from an MS Project closed file into my MS Word document something very similar to what is being done above by Hatman, please i need help in going about achieving this t work.
i appreciate your suggestions.
 
Upvote 0
Hello guys, i'm working on getting data from an MS Project closed file into my MS Word document something very similar to what is being done above by Hatman, please i need help in going about achieving this t work.
i appreciate your suggestions.

Pulling data out of files without opening them is problematic at best, and I don;t recommend trying it unless yout know the raw filetype encoding very well (unless it's XML based... but that's a different story).

Start by adding a reference to the MS Project library in your VBA Project... then create a new project.application object, and open the target file, like what I listed in my earlier post. From there, it;s a matter of using the Locals window to investigate the file-structure and write code to parse the Tasks collection and pull teh properties you are lookign for... each task has around 1200 properties, so you need to know what you are lookign for specifically...
 
Upvote 0
Hey Hatman,
Thanks very much, followed your instructions and i figured it out and it now works exactly as i want i to.
Thanks.
 
Upvote 0
I'm glad it made sense to you... I short-changed you on the details with the intention of posting more in-depth sample code when I got back to work on Mondy (if you needed it). Sometimes it's better to figure out from a gentle nudge, and I'm glad it worked out for you.
 
Upvote 0

Forum statistics

Threads
1,224,593
Messages
6,179,791
Members
452,942
Latest member
VijayNewtoExcel

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top