in reply to how to convert this VB code to perl

Using OLE with Perl may help.

  • Comment on Re: how to convert this VB code to perl

Replies are listed 'Best First'.
Re^2: how to convert this VB code to perl
by proton-69 (Novice) on Jan 27, 2009 at 18:31 UTC
    Does not help...:(

      :-( Well...

      ... $obj_sel->InsertBreak({Type => 'PageBreak'}) ; doesn't look to me like a complete program... Can one assume that you've done all the things necessary to open the document you want to insert a page break into and then select the place at which to insert it ? It's not clear whether your issue is with driving OLE in general or with this method in particular.

        Code goes like this
        #! c:\perl\bin\perl use strict; use warnings; use Win32::OLE; my $file = $ARGV[0]; my $image = $ARGV[1]; my $count = $ARGV[2]; my $class = "Word.Application"; my $word_ref = Win32::OLE->new($class) || die ("Failed to launch Word +due to", Win32::OLE::LastError()); $word_ref->{'Visible'} = 1; # Add the doc my $doc = $word_ref->Documents->Add; my ($obj_sel, $obj_shape); for (my $i=0; $i < $count; $i++) { $obj_sel = $word_ref->Selection; $obj_shape = $doc->Shapes; # add image $obj_shape->AddPicture($image); # add page break add_pagebreak($obj_sel); } # Save the file $word_ref->ActiveDocument->SaveAs($file); # destory objs undef $obj_sel; undef $obj_shape; $word_ref->Quit(); # destory contructor for word app undef $word_ref;
        I want to add $count number of images in doc file so that i need to put page break after each pic insert.