偶现在使用ComObj的方式调用Word,已经能够正常的调出Word程序了,但这个Word是单独的,想要实现MDI的那样的方式,将调出的Word窗口作为MDI的子窗体不晓得是否可以,请大家帮忙。

解决方案 »

  1.   

    应该oleContainer控件可以实现!
      

  2.   

    unit Main;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, OleCtnrs, ExtCtrls, OleCtrls, SHDocVw;type
      TForm1 = class(TForm)
        OleContainer1: TOleContainer;
        Panel1: TPanel;
        Button1: TButton;
        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);
    begin
      OleContainer1.CreateLinkToFile(ExtractFilePath(Application.ExeName) + 'default.ppt',False);
      //OleContainer1.DoVerb(0);   //直接F5了
      //OleContainer1.OleObject.Preview;
    end;procedure TForm1.Button2Click(Sender: TObject);
    var
      V:Variant;
    begin
      oleContainer1.CreateObject('Excel.Sheet.8',false);
      oleContainer1.DoVerb(ovshow);
      V:=OleContainer1.OleObject;
      V.Application.CommandBars['Standard'].Visible := True;
      V.Application.CommandBars['Formatting'].Visible := True;   //不显示菜单及工具栏
    end;
    end.
      

  3.   

    多些楼上的指点,不过使用这种方式的话,那么VBA的命令是否可用呢?