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

The Problem:
The script crashes whenever I call the FilePageSetupHeader method on an MS Project OLE object.

The Code:
(simplified down to just show the error)

use strict; use Win32::OLE; use Win32::OLE::Variant; my $file = "C:\\blah\\test.mpp"; print "Opening " . "$file \n"; my $app = Win32::OLE->GetObject($file) or die "Couldn't open project" . Win32::OLE->LastError(); $app->{visible} = 1; $app->FilePageSetupHeader({ Name => 'Name', Text => 'test project', Alignment => '1' });

Other Info:
I'm able to open MS Project files, read/write the data, and resave them without any problem. I used Microsoft's oleviewer.exe to find the method names and here is the MSDN page for this method.

References:
I've used the following information to get me this far:
Microsoft Project and Perl Node
Activestate's OLE with Perl page.
Perl.com's Automating Windows Applications with OLE article.

Does anyone have a solution to this problem? Can anyone at least verify it? I'm running Windows XP with SP2.

Thanks in advance.

-----------------------------------
Washizu
Odd Man In: Guns and Game Theory

Replies are listed 'Best First'.
Re: MS Project, OLE, and the FilePageSetupHeader method
by VSarkiss (Monsignor) on Nov 23, 2005 at 21:09 UTC

    All I can provide is a negative data point. Using your code on a random MS Project file, also under Win XP, didn't produce any error. Here's a transcript (I added print "Made it" to the end of your snippet):

    Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. H:\>perl washizu.pl Opening H:\test.mpp Made it H:\>perl -v This is perl, v5.8.4 built for MSWin32-x86-multi-thread (with 3 registered patches, see perl -V for more detail) Copyright 1987-2004, Larry Wall Binary build 810 provided by ActiveState Corp. http://www.ActiveState. +com ActiveState is a division of Sophos. Built Jun 1 2004 11:52:21 ...
    I also have MS Project 2000 installed (9.0.2001.0219 SR-1 according to the "Help About").

    Good luck. If you figure it out, update your node or post a reply.

      ahh. You may have hit on it. I'm running MS Project 97.
      Upon further inspection, I'm running MS Project 2000. :(

      -----------------------------------
      Washizu
      Odd Man In: Guns and Game Theory