【问题标题】:perl Win32::OLE ExportAsFixedFormat syntax for powerpoint用于 powerpoint 的 perl Win32::OLE ExportAsFixedFormat 语法
【发布时间】:2012-01-24 02:07:11
【问题描述】:

我在使用 perl(草莓)和 win32::ole 使用 powerpoint 时遇到问题(来自 office2010) 将 ppt(x) 转换为 pdf。

我可以使用导出功能很好地导出为 jpg,但函数 ExportAsFixedFormat 的语法非常晦涩,而且总是给我 Win32::OLE(0.1709) error 0x80020011: "Does not support a collection".

这是我正在尝试的示例

    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"); 

第二个参数ppFixedFormatTypePDF应该是2

第三个参数 'ppFixedFormatIntentPrint' 应该是 2

谁能推荐一个可行的例子?

【问题讨论】:

    标签: perl powerpoint win32ole


    【解决方案1】:

    只是为了完成 golemwashere 的回答:

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

    这在 windows 7 上使用 powerpoint 2007 有效,但必须忽略返回值。

    【讨论】:

      【解决方案2】:

      我解决了

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

      很难发现 32 = pdf 格式 并且 $outfile 还需要正斜杠:/ 在路径中(使用 \ 我得到了令人困惑的错误)。

      【讨论】:

      • 您应该使用 Win32::OLE::Const 'Microsoft PowerPoint; 来表示常量,例如 ppFixedFormatTypePDF File::SpecPath::Class 来构建路径或转义斜线,如 `"C:\\Users\\golemwashere \\文档”等
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-27
      • 2010-10-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多