在delphi6下用Server中的 TPowerPointApplication和TPowerPointPresentation,可以
对PowerPoint进行操作.当然你也可以用CreateOleObject('PowerPoint.application')对
PowerPoint进行操作.
下面是一段试验代码,其中
pptA: TPowerPointApplication;
pptP: TPowerPointPresentation;
另外两个对象是
ssSet: SlideShowSettings; 用于设置幻灯片的放映属性
ssWin: SlideShowWindow; 用于播放幻灯片的控制
ssWin有一个成员对象View可以控制幻灯片放映First,Next,Previous,Last,以及停止
放映Exit,这样的话就可以控制循环播放次数了.
========================================================
var
ssSet: SlideShowSettings;
ssWin: SlideShowWindow;
procedure TForm1.Button1Click(Sender: TObject);
var
i: integer;
begin
pptA := TPowerPointApplication.Create(self);
pptA.Visible := msoTrue;
PPtP.ConnectTo(pptA.Presentations.Open('e:/sy/study/sample/test.ppt', msoFalse, msoFalse, msoTrue));
ssSet := PPtP.SlideShowSettings;
ssSet.LoopUntilStopped := msoFalse;
ssSet.ShowType := ppShowTypeSpeaker;
ssSet.Run;
ssWin := PPtP.SlideShowWindow;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
ssWin.View.Next;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
ssWin.View.Exit;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
try
pptA.Disconnect;
pptA.Quit;
if assigned(pptA) then pptA.Free;
except
showmessage('PowerPoint has already closed!');
end;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
try
pptA.Disconnect;
pptA.Quit;
if assigned(pptA) then pptA.Free;
except
showmessage('PowerPoint has already closed!');
end;
end;