试试这个效果,
var
    Word:Variant;
begin
    Word:=CreateOLeObject('Word.application');
    Word.visible:=True;
    Word.documents.add;    Richedit1.SelAttributes.Color := clRed;
    Richedit1.SelAttributes.Style := [fsBold];
    Richedit1.lines.Add('公式名称:编辑');
    Richedit1.SelStart:=14+Length(trim('公式名称:编辑'));
    Richedit1.Tag:=Richedit1.SelStart-1;
    Richedit1.SelLength:=4;
    Richedit1.SelectAll;
    Richedit1.CopyToClipboard;
    Word.Selection.Paste;
end;从word里向外读的时候
在里面copy就可以了。

解决方案 »

  1.   

    试试这个效果,
    var
        Word:Variant;
    begin
        Word:=CreateOLeObject('Word.application');
        Word.visible:=True;
        Word.documents.add;    Richedit1.SelAttributes.Color := clRed;
        Richedit1.SelAttributes.Style := [fsBold];
        Richedit1.lines.Add('公式名称:编辑');
        Richedit1.SelStart:=14+Length(trim('公式名称:编辑'));
        Richedit1.Tag:=Richedit1.SelStart-1;
        Richedit1.SelLength:=4;
        Richedit1.SelectAll;
        Richedit1.CopyToClipboard;
        Word.Selection.Paste;
    end;从word里向外读的时候
    在里面copy就可以了。
      

  2.   

    下面是调用word模版的程序,但是跟你要实现的有一定的差别,以下仅供你参考:procedure TForm1.Button2Click(Sender: TObject);//按钮事件
    var fn,i:OleVariant;
    begin
       with WordApplication1 do
       begin
          try
           Connect();
           fn:='d:\小何\wordprt\wordot\01.dot';//指定已建模板的路径。
           i:=false;
    //当i为true或零并且已有指定模板,系统根据所建模板再重新建一个模板,
    //若以前没有建模板则系统将会出现有关文档不存在或文档路径出错等信息
    //若i为false或1并且已有指定模板,系统将会启动所指定模板。
            Documents.Add(fn,i);
            Replace('Edit1',Edit1.Text);//替换文本
            Replace('Edit2',Edit2.Text);
            Replace('Edit3',memo1.Text);
          finally
            Visible:=True;
            Disconnect();
          end;
       end;
    end;procedure TForm1.Replace(Source,Dest:string);//replace函数
    var FindText,MatchCase,MatchWholeWord,MatchWildCards,MatchSoundsLike,
        MatchAllWordForms,FForward,Wrap,Format,ReplaceWith,Replace,
        MatchKaShida,MatchDiacritics,MatchAlefHamza,MatchControl:OleVariant;
        What,Which,Count,CName:OleVariant;
    begin
       with WordApplication1 do
         begin
            FindText:=Source;
            MatchCase:=True;
            MatchWholeWord:=False;
            MatchAllWordForms:=False;
            MatchSoundsLike:=False;
            FForward:=True;
            Wrap:=False;
            Format:=False;
            //ReplaceWith:='';
            replaceWith:=dest;
            replace:=true;
            //Replace:=False;
            MatchKaShida:=False;
            MatchDiacritics:=False;
            MatchAlefHamza:=False;
            MatchControl:=False;
    Selection.Find.Execute(FindText,MatchCase,MatchWholeWord,MatchWildCards,MatchSoundsLike,
                                   MatchAllWordForms,FForward,wrap,Format,ReplaceWith,Replace);
    //Selection.TypeText(Dest);该语句和前面的两条语句结合后word中被替换的文字是长文本,而如果用现有的语句,则word中被替换的文本最长为504个字节。
            What:=wdGotoPage;
            Which:=wdGotoNext;
            Count:=1;
            CName:='';
            Selection.GoTo_(What,Which,Count,CName);
         end;
    end;
      

  3.   

    不知道 有没有读取word 文档的控件????
      

  4.   

    使用TOlecontainter控件,可以将word打开和修改
      

  5.   

    早知道你要用控件就好了
    用TOlecontainter,点右鍵insert object
    然后
    OleContainer1.LoadFromFile('C:\temp.doc');就行了。
      

  6.   

    哈哈netlib(河外孤星) 可真是辛苦你了。
      

  7.   

    我没用过这么复杂的。只是用过把数据输出到我word里,让用户打印,他们不喜欢delphi的报表(可能我设计得不好吧,哎,水平低,损坏delphi形象了,我该死)