M
maozhuxi
Unregistered / Unconfirmed
GUEST, unregistred user!
PPtP.ConnectTo(pptA.Presentations.Open('D:/my_pro/out_ppt/1.ppt', msoFalse, msoFalse, msoTrue));我是想打开ppt文件,但是运行到这里就报未知错误。下面是我的源代码:button1和button2的用处一样都是想打开ppt,但是就是报错,实在没办法。unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,comobj,office2000, OleServer, PowerPointXP;type TForm1 = class(TForm) Memo1: TMemo; Button1: TButton; OpenDialog1: TOpenDialog; PowerPointApplication1: TPowerPointApplication; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);var PPT, PP: Variant; i,j:integer; s:string;begin PPT := CreateOleObject('PowerPoint.Application') ; PPT.visible:=msoTrue; showmessage('qq'); //pp := PPT.Presentations.Open('D:/my_pro/out_ppt/1.ppt', True, True, False); opendialog1.Execute; pp := ppt.Presentations.Open(opendialog1.FileName,msoFalse,msoFalse, msoTrue); for I := 1 to pp.Slides.Count do for J := 1 to pp.Slides.Item(I).Shapes.Count do if pp.Slides.Item(I).Shapes.Item(J).TextFrame.HasText then S := S + #13#10 + pp.Slides.Item(I).Shapes.Item(J).TextFrame.TextRange.Text; Memo1.Text := S; PPT.Quit; PP := UnAssigned; PPT := UnAssigned;end;procedure TForm1.Button2Click(Sender: TObject);varpptA: TPowerPointApplication;pptP: TPowerPointPresentation;ssSet: SlideShowSettings;ssWin: SlideShowWindow;beginpptA := TPowerPointApplication.Create(self);pptA.Visible := msoTrue;PPtP.ConnectTo(pptA.Presentations.Open('D:/my_pro/out_ppt/1.ppt', msoFalse, msoFalse, msoTrue));ssSet := PPtP.SlideShowSettings;ssSet.LoopUntilStopped := msoFalse;ssSet.ShowType := ppShowTypeSpeaker;ssSet.Run;ssWin := PPtP.SlideShowWindow;end;end.