这条语句是实现选择WORD里面的一个文本框,VBA代码为:ActiveDocument.Shapes("Text Box 2").Select这句话在DELPHI里怎么写呢? 我改成:WordDoc.Shapes('Text Box 5').Select;结果报错:
Project raised exception class EOleException with message "Shapes' is not a method".
Process stopped. Use Step or Run to continue.

解决方案 »

  1.   

    var
      Template,NewTemplate,DocumentType,Visible: OleVariant;  
      Orientation, Left, Top, Width, Height, Anchor:OleVariant;
      WordApp: TWordApplication;
    begin
      WordApp:=TWordApplication.Create(Application);
      WordApp.Visible:=True;
      Template:='';
      NewTemplate:=False;
      DocumentType:=wdNewBlankDocument;
      Visible:=True;
      WordApp.Documents.Add(Template,NewTemplate,DocumentType,Visible);
      Orientation:=msoTextOrientationDownward;
      Left:=10;
      Top:=10;
      Width:=20;
      Height:=20;
      Anchor:=WordApp.ActiveDocument.Content;
      WordApp.ActiveDocument.Shapes.AddTextbox(Orientation, Left, Top, Width, Height, Anchor);
    end;