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

Hi,
Can't get this
use Win32::OLE; use Win32::OLE::Variant; use strict; my $app = Win32::OLE->GetObject("c:/test.mpp") or die "Couldn't open p +roject: $!"; my $project = $app->{Projects}->Item(1);
to work and get back
Can't locate object method "Item" via package "test.mpp" (perhaps you +forgot to load "test.mpp"?) at project1.pl line 7.

Anyone know what might be wrong?
It's on XP, Perl 5.8.2, and the Win32 stuff is all there as far as I know, as is the dummy project file.
Thanks,
David

Replies are listed 'Best First'.
Re: Perl and MS Project
by Wonko the sane (Curate) on Mar 23, 2004 at 13:29 UTC
    Hello,

    I have never used any of these packages, but the error you are getting
    Is very much like the error you would get if the string 'test.mpp'
    was the value of "$app->{Projects}". In other words I think you are trying
    to call a method on a string value.

    This code produces a similar error.

    #!/usr/local/bin/perl5.6.0 -w use strict; my $app = { Projects => 'test.mpp' }; my $r = $app->{Projects}->Item(1);

    Hope that helps.

    Wonko
      ...not really. Not sure what you're getting at?
      That code was lifted from another bit of the Monastery and since I've got other Win32 things running just fine, I kind of expected it just to work. So either the code is wrong or I've something missing from my PC but am not sure which it is...
      Thanks,
      David