1

I have trouble using perl (strawberry) and win32::ole using powerpoint (from office2010) to convert ppt(x) to pdf.

I can export to jpgs fine with Export function but the function ExportAsFixedFormat has a quite obscure syntax and alwawys gives me Win32::OLE(0.1709) error 0x80020011: "Does not support a collection".

this is a sample of what I am trying

    my $ppoint = Win32::OLE->new('PowerPoint.Application', 'Quit');
    my $Presentation = $ppoint->Presentations->Open("$infile") || die("Una +ble to open document ", Win32::OLE->LastError()) ; 
    $Presentation->ExportAsFixedFormat("$outfile", 2, 2, "msoCTrue", "ppPrintHandoutHorizontalFir +st", "ppPrintOutputFourSlideHandouts", "msoFalse", "", "" , "", "Fals +e", "False", "False", "False", "False"); 

second parameter ppFixedFormatTypePDF should be 2

third param 'ppFixedFormatIntentPrint' should be 2

Can anyone suggest a working example?

Mouna Cheikhna
  • 38,870
  • 10
  • 48
  • 69
golemwashere
  • 159
  • 1
  • 7

2 Answers2

1

Just to complete the answer from golemwashere:

use Win32::OLE::Const 'Microsoft PowerPoint';
...
$Presentation->SaveAs("$outfile",ppSaveAsPDF, 1);

This works using powerpoint 2007 on windows 7, but the return value has to be ignored.

Karl Forner
  • 4,175
  • 25
  • 32
-1

I solved using

$Presentation->SaveAs("$outfile", 32);

it was tricky finding that 32 = pdf format and also $outfile needed foward slashes : / in path (with \ I got confusing errors).

golemwashere
  • 159
  • 1
  • 7
  • 4
    You should use use `Win32::OLE::Const 'Microsoft PowerPoint;` for constants such as `ppFixedFormatTypePDF ` and either `File::Spec` or `Path::Class` for constructing paths or escape the slashes as in `"C:\\Users\\golemwashere\\Documents" etc. – Sinan Ünür Oct 01 '11 at 11:17