plugNPlay has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks - Have any of you automated MSProject using Win32::OLE? In particular, have you been able to do GetObject on projects that are saved within Project databases? If a standalone Project file is "bar.mpp", then a Project database can contain several projects: "foo.mpd" will have within it "bar.mpp", "bar2.mpp", etc. How do I access projects within a database? The following code gives a "No such file or directory" error. (Create the directory, database, and file first!)
use strict; use Win32::OLE; my $proj = "<C:\mydir\proj.mpd>\proj.mpp"; my $Object = Win32::OLE->GetObject( $proj ) || die $!;
Many thanks.

Replies are listed 'Best First'.
Re: Win32::OLE and MSProject
by FitTrend (Pilgrim) on Feb 24, 2005 at 16:21 UTC

    If you double quote your windows path using \, you will need to escape them.

    my $proj = "C:\\mydir\\proj.mpd\\proj.mpp";
    or
    my $proj = 'C:\mydir\proj.mpd\proj.mpp';
      That's getting me somewhere. Thanks M a r c!
Re: Win32::OLE and MSProject
by esskar (Deacon) on Feb 24, 2005 at 16:21 UTC
    i'm not sure but try
    my $Object = Win32::OLE->GetObject("MSProject.Project.4_1")
    for creating the object. then you have to open the database. in FoxPro it is Object.application.FileOpen(...)
    HTH
Re: Win32::OLE and MSProject
by dws (Chancellor) on Feb 25, 2005 at 00:29 UTC
    There's more info on accessing MS Project via OLE using Perl here.