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


In reply to MS Project, OLE, and the FilePageSetupHeader method by Washizu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.