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

Hi, evrybody, I'm new on this forum so sorry for all mistakes. I have a problem with perl script for ms project. I can't add new task in different row, only add after last one is possible Please help me.

use Win32::OLE; use Win32::OLE::Variant; use Win32::OLE::Const 'Microsoft Project'; use Win32::OLE::NLS qw( :LOCALE :DATE :TIME ); use Data::Dumper; use Cwd; my $cwd = getcwd; my $mpp = $cwd."\/EUCD_SCHED.mpp"; #EUCD_SCHED my $app = Win32::OLE->GetObject($mpp) or die "Couldn't open project"; my $project = $app->Projects(1); my $noOfTask = $app->Tasks->Count(); # my $selectedTask = $app->SelectRow(64); #RowInsert EditInsert if($app->Tasks(70)->{'EditInsert'}) { print "\n>>>> OK <<<<\n"; } else { print "\n>>>> no OK <<<<\n"; }

Replies are listed 'Best First'.
Re: MS Project
by GrandFather (Saint) on Feb 16, 2012 at 00:04 UTC

    It's likely that few monks use or have access to Microsoft Project. However the general advice for OLE scripting issues is "record a VBA script to do it, then translate the steps". Can you achieve what you want using Microsoft Project's built in macro/scripting support? If so either mimic that script using Perl and OLE, or if you can't make that work show us the VBA that was generated and someone may then be able to help.

    True laziness is hard work

      Hi, I know about this:) i always record VBA macro it's simlpy way to write something very fast, but this time VBA for MS project is different from VBA for Excel, so I can't translate e.g. 'EditInsert' or 'RowInsert' from VBA to PERL :(

        The answer is:

        my $app = Win32::OLE->GetObject($mpp) or die "Couldn't open project"; my $project = $app->Projects(1); $app->Tasks->Add("task title", $numberOfRow);