添加一个System面板上的OLEContainer控件,一个openDialog控件,一个Button
在Button的 click事件中加入代码:
procedure TForm1.Button1Click(Sender: TObject);
begin
if opendialog1.Execute then
  begin
  olecontainer1.CreateObjectfromfile(opendialog1.FileName,false );
  olecontainer1.run;
  end;
end;
运行时点button,选择一个word文档,然后双击OLEContainer就可以了

解决方案 »

  1.   

    首先创建 Excel 对象,使用ComObj:procedure TForm1.Button1Click(Sender: TObject);
    var
      wordApp: Variant;
    begin
      if FileExists('e:\delphi\word\wang1.doc') then
      begin
        wordApp:=CreateOleObject('word.Application');
        wordApp.Documents.Open('e:\delphi\word\wang1.doc');
        wordApp.Visible :=True;
      end
      else
      begin
        Application.Messagebox('对不起,没有相应的文件!','提示',MB_OK+MB_ICONQUESTION);
      end;end;
      

  2.   

    首先创建 word 对象,使用ComObj:
    即在uses声明中加入comobj