以前写的一些关于PowerPoint的代码,另外看一下office2000的一个帮助VBAPPT9.CHM,
在光盘上有,里面有十分详细的PowerPoint对象结构图,可以说把这个结构图搞清楚了,
你看怎么玩就怎么玩了.
unit fmpptDemp;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, MSPpt2000, OleServer, Office2000;
type
TForm1 = class(TForm)
pptA: TPowerPointApplication;
pptP: TPowerPointPresentation;
pptS: TPowerPointSlide;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button5: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button5Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
connected: boolean;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
const
LoopCnt = 3;
{$R *.dfm}
var
ssSet: SlideShowSettings;
ssWin: SlideShowWindow;
// 打开一个ppt文件,并进入放映模式
procedure TForm1.Button1Click(Sender: TObject);
begin
if not connected then
begin
pptA.Connect;
connected := True;
end;
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;
PPts.ConnectTo(PPtP.Slides.Item(1));
end;
//下一张幻灯片
procedure TForm1.Button2Click(Sender: TObject);
begin
ssWin.View.Next;
end;
// 停止放映
procedure TForm1.Button3Click(Sender: TObject);
begin
ssWin.View.Exit;
end;
// 关闭PowerPoint
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.Button5Click(Sender: TObject);
var
objShape: MSPpt2000.Shape;
begin
objShape := pptS.Shapes.AddLabel(msoTextOrientationHorizontal, 1, 1, 10, 12);
objShape.Name := 'myobj1';
pptA.ActiveWindow.Selection.TextRange.Text := 'add by programmer';
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
connected := False;
end;
end.