Ich muss eine große Anzahl von Powerpoint-Dateien mit variierendem Text (Programm von Konferenzsitzungen) produzieren. Ich versuche das mit Perl und Win32 :: OLE zu tun. Dies funktioniert gut mit Ausnahme der Einstellung der Farbe des Textes, den ich poste. Alles, was ich einstellen kann, ist der Wert für Rot in RGB, aber nicht die anderen Farben. Ich verwende Powerpoint 2010. Außerdem kann ich die Farbe in Powerpoint über VBA ändern.Perl Win32 Powerpoint Einstellung Schriftfarbe
Hier ist der Code, den ich benutze (kommentiert mit # - sind einige Optionen, die ich ausprobiert habe und das hat nicht funktioniert).
use strict;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft PowerPoint';
$Win32::OLE::Warn = 2; # Throw Errors, I'll catch them
my $PptApp = Win32::OLE->GetActiveObject('PowerPoint.Application')|| Win32::OLE->new('PowerPoint.Application', 'Quit');
$PptApp->{Visible} = 1;
my $Presentation = $PptApp->Presentations->Open({FileName=>'<input-filename.ppt>',ReadOnly=>1});
my $Slide = $Presentation->Slides(1);
$Slide->{Name} = "Slide1";
my $TextBox=$Slide->Shapes->AddTextbox({Orientation=>1,
Left=>25,
Top=>25,
Width=>550,
Height=>50,
});
$TextBox->TextFrame->TextRange->{Text} ="Big Ole Test";
$TextBox->TextFrame->TextRange->Font->{Color} = 255;
#- $TextBox->TextFrame->TextRange->Font->{Color} => ({RGB=>(Red=>86, Green=>55, Blue=>201)});
## Black
#- $TextBox->TextFrame->TextRange->Font->Color->RGB=>[255,255,255];
## Black
#- $TextBox->TextFrame->TextRange->Font->Color => [255,255,255];
## Black
#- $TextBox->TextFrame->TextRange->Font->Color->RGB => 'RGB(255,255,255)';
## Black
#- $TextBox->TextFrame->TextRange->Font->{Color}->{RGB}=>[255,255,255];
## Black
$Presentation ->SaveAs('<output-filename.ppt>');