试试下面的
var c:TClipboard;
atype,tmp
levariant;
begin
try
try
PowerPointApplication1.Connect;
except on E: Exception do
begin
E.Message := 'PowerPoint does not appear to be installed';
raise;
end;
end;
PowerPointApplication1.Visible := 1;
Form1.SetFocus;
PowerPointPresentation1.ConnectTo(PowerPointApplication1.Presentations.Add(1));
PowerPointSlide1.ConnectTo(PowerPointPresentation1.Slides.Add(PowerPointPresentation1.Slides.Count + 1, 1));
with PowerPointSlide1 do
begin
Layout := 10;
FollowMasterBackground := 0;
Background.Fill.PresetGradient(2, 2, 10);
Shapes.Item(1).TextFrame.TextRange.InsertAfter('test');
c:=TClipboard.Create;
c.Assign(Image1.Picture.Bitmap);
Shapes.Paste;
{Set time displayed for each slide}
SlideShowTransition.AdvanceOnTime := 1;
SlideShowTransition.AdvanceTime := 2;
c.Free;
tmp:=True;
atype:=ppSaveAsPowerPoint7;
caption:=self.PowerPointPresentation1.GetNamePath;
self.PowerPointPresentation1.SaveAs('c:/1.ppt',atype,tmp);
end;
except
on E: Exception do
begin
Showmessage(E.Message);
PowerPointApplication1.Disconnect;
end;
end;
end;