使用win32 :: OLE for powerpoint只是在保存时挂起。我发现excel和word应用程序没有问题,但是使用powerpoint它会在保存时挂起。我基本上在远程窗口上打开一个powerpoint文件共享save和saveas。在本地它工作得很好,但保存共享只是挂起。
以下代码。
# Powerpoint save on remote windows share
$MAP_DRIVE = 'X:';
$file = "ppt1.ppt";
$save = 1;
my $str = "";
$str .= `date /T`;
$str .= `time /T`;
require Win32::OLE;
use Win32::OLE::Const 'Microsoft PowerPoint';
my $ppt = Win32::OLE->new('PowerPoint.Application','Quit');
$ppt->{Visible} = 1;
my $filehandle = $ppt->Presentations->Open({FileName=>"$MAP_DRIVE\\$file"}) ;
if(Win32::OLE->LastError())
{
print Win32::OLE->LastError();
exit(0);
}
# Add slides
my $slide = $filehandle->Slides->Add({Index=>1,Layout=>ppLayoutText});
$slide->{Name} = "Slide-AUTO";
my $textbox = $slide->Shapes->AddTextbox({Orientation=>1,Left=>5,Top=>5,Width=>250,Height=>250});
$textbox->TextFrame->TextRange->{Text} = "AUTO - $str";
my $title = $slide->Shapes->{Title};
$title->TextFrame->TextRange->{Text} = "AUTO EDIT PPT";
if ($saveas)
{
$file =~/([\w+0-9_\\\/:\s]+)\.ppt/;
my $saveas = $1."saveas.ppt";
$filehandle->SaveAs({FileName=>"$MAP_DRIVE\\$saveas"}) ;
#Also tried with the following
#$ppt->ActivePresentation->SaveAs({FileName=>"$MAP_DRIVE\\$saveas"});
if (Win32::OLE->LastError())
{
print Win32::OLE->LastError();
exit(0);
}
if ($save)
{
$filehandle->Save();
}
$filehandle->Close();
$ppt->Quit();