2017-02-10 1 views
0

を失敗し、私はパワーポイントファイルをロードしようとするが、インストールMSパワーポイントビューア後

unit Unit1; 

interface 

uses  Comobj, 
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
    Dialogs, StdCtrls, ExtCtrls,Office_TLB, office97, PowerPointXP;//, ExtCtrls; 

type 
    TForm1 = class(TForm) 
    Button1: TButton; 
    Panel1: TPanel; 
    procedure Button1Click(Sender: TObject); 
    private 
    { Private declarations } 
    public 
    { Public declarations } 
    end; 

var 
    Form1: TForm1; 

implementation 

{$R *.dfm} 

procedure TForm1.Button1Click(Sender: TObject); 
const 
    ppShowTypeSpeaker = 1; 
    ppShowTypeInWindow = 1000; 
    SHOW_FILE = 'C:\Users\myname\Downloads\practicepowerpoint.ppt'; 
var 
    oPPTApp: OleVariant; 
    oPPTPres: OleVariant; 

    screenClasshWnd: HWND; 
    pWidth, pHeight: Integer; 

    function PixelsToPoints(Val: Integer; Vert: Boolean): Integer; 
    begin 
    if Vert then 
     Result := Trunc(Val * 0.75) 
    else 
     Result := Trunc(Val * 0.75); 
    end; 

begin 
    try 
    oPPTApp := CreateOleObject('PowerPoint.Application'); 
    except 
    showmessage('no ppt');; 
    exit; 
    end; 
    oPPTPres := oPPTApp.Presentations.Open(SHOW_FILE, True, True, False); 
    pWidth := PixelsToPoints(Panel1.Width, False); 
    pHeight := PixelsToPoints(Panel1.Height, True); 
    oPPTPres.SlideShowSettings.ShowType := ppShowTypeSpeaker; 
    oPPTPres.SlideShowSettings.Run.Width := pWidth; 
    oPPTPres.SlideShowSettings.Run.Height := pHeight; 
    screenClasshWnd := FindWindow('screenClass', nil); 
    Windows.SetParent(screenClasshWnd, Panel1.Handle); 

end; 

end. 

以下のコード行

oPPTApp := CreateOleObject('PowerPoint.Application'); 

を実行してエラーが発生します。

はちょうど私がパワーポイントではなく、パワーポイントビューアをインストールする必要があれば前

+0

です。このようなペアレンタルはうまくいきません。別の方法を見つける。 –

答えて

0

コード

コメント歓迎を実行するだろうはい、「Powerpoint.Applicationは」パワーポイントを開始します。私はパワーポイントビューアを使用することをお勧めしません。これは本当に古いプログラムです(2010年以前)。私はあなたがこのプログラムを自動化できるかどうか分かりません。 pptxを表示する新しい方法は、Powerpoint online

関連する問題