我需要在paradox数据中保存WORD 文档。我该用那种字段类型。
在DELPHI 里如何通过程序自动把WORD 文档的内容保存到数据库。
另外下面这个语名的参数那么写:
WordDocument.Range.InsertFile(     );

解决方案 »

  1.   

    1。2。TBlobField(Query.FieldByName('word')).LoadFromFile(Opendialog.Filename);3。WordDocument.Range.InsertFile(FileName:=Opendialog.Filename);
       -------------------
       可用WordApplication.Selection.代替(如果上面语句出错)
      

  2.   

    楼上
    WordDocument.Range.InsertFile
    有五个参数,
    我不知道这五个参数如何设置
      

  3.   

    楼上,
    [Error] Unit1.pas(85): Not enough actual parameters
      

  4.   

    我是这样写的
    WordDocument.Range.InsertFile('e:\1.doc');
      

  5.   

    写成这样看看:
    WordDocument.Range.InsertFile(FileName:='e:\1.doc');
      

  6.   

    我是这样写的
    WordDocument.Range.InsertFile('e:\1.doc');
    出现了下列错误
    [Error] Unit1.pas(85): Not enough actual parameters
      

  7.   

    上面好象不行,试试这个:
    WordDocument.Range.InsertFile('E:\aaa.txt', EmptyParam, EmptyParam, EmptyParam, EmptyParam);
      

  8.   

    换成你的文件名:
    WordDocument.Range.InsertFile('e:\1.doc', EmptyParam, EmptyParam, EmptyParam, EmptyParam);
      

  9.   

    使用wordappalication 组件,代码如下
    启动Word时用如下代码: 
    begin
    try 
    Wordapplication.Connect; 
    except 
    MessageDlg(’Word may not be installed’, mtError, [mbOk], 0); 
    Abort; 
    end; 
    Wordapplication.Visible := True; 
    WordApplication.Caption := ’Delphi automation’; 
    end; 关闭Word用如下代码。如果想保存Doc文件,请修改SaveChanges变量的内容: 
    var 
    SaveChanges, OriginalFormat, Routedocument. OleVariant; 
    begin 
    SaveChanges := WdDoNotSaveChanges; 
    OriginalFormat := UnAssigned; 
    Routedocument.nbsp:= UnAssigned; 
    try 
    WordApplication.Quit(SaveChanges, OriginalFormat, Routedocument.; 
    WordApplication.Disconnect; 
    except 
    on E: Exception do 
    begin 
    Showmessage(E.Message); 
    WordApplication.Disconnect; 
    end; 
    end; 
    end; 让Word打开一个指定的文件,需要先放置OpenDialog,然后调用WordApplication.document..Open: 
    var 
    ItemIndex :OleVariant; 
    FileName, ConfirmConversions, ReadOnly, AddToRecentFiles, 
    Passworddocument. PasswordTemplate, Revert, 
    WritePassworddocument. WritePasswordTemplate, Format: OleVariant; 
    begin 
    if not dlgOpen.Execute then 
    Exit; {Open document. 
    FileName := dlgOpen.FileName; 
    ConfirmConversions := False; 
    ReadOnly := False; 
    AddToRecentFiles := False; 
    Passworddocument.nbsp:= ’’; 
    PasswordTemplate := ’’; 
    Revert := True; 
    WritePassworddocument.nbsp:= ’’; 
    WritePasswordTemplate := ’’; 
    Format := wdOpenFormatdocument. WordApplication.document..Open( FileName, ConfirmConversions, 
    ReadOnly, AddToRecentFiles, Passworddocument. PasswordTemplate, 
    Revert, WritePassworddocument. WritePasswordTemplate, Format ); {Assign Worddocument.nbspcomponent} 
    ItemIndex := 1; 
    Worddocument.ConnectTo(WordApplication.document..Item(ItemIndex)); {Turn Spell checking of because it takes a long time if enabled and slows down Winword} 
    WordApplication.Options.CheckSpellingAsYouType := False; 
    WordApplication.Options.CheckGrammarAsYouType := False; 
    end; 让Word替换标记字符串要使用Worddocument.Range.Find.Execute,这里用Delphi替换了<#Name>: 
    var 
    FindText, MatchCase, MatchWholeWord, MatchWildcards, MatchSoundsLike, 
    MatchAllWordForms, Forward, Wrap, Format, ReplaceWith, Replace: OleVariant; 
    begin 
    FindText := ’<#Name>’; 
    MatchCase := False; 
    MatchWholeWord := True; 
    MatchWildcards := False; 
    MatchSoundsLike := False; 
    MatchAllWordForms := False; 
    Forward := True; 
    Wrap := wdFindContinue; 
    Format := False; 
    ReplaceWith := ’Delphi’; 
    Replace := True; Worddocument.Range.Find.Execute( FindText, MatchCase, MatchWholeWord, 
    MatchWildcards, MatchSoundsLike, MatchAllWordForms, Forward, 
    Wrap, Format, ReplaceWith, Replace ); end;
      

  10.   

    use comobj,word97
    ...var word_sj:Variant;
        lastparagraph:Integer;
    BEGIN
    word_sj:=createoleobject('word.application');
    word_sj.documents.open('第一个文件.doc');
    word_sj.documents.item(1).Range.InsertAfter(#13);
    word_sj.documents.open('第二个文件.doc');
    word_sj.documents.item(1).range.copy;
    word_sj.documents.item(1).close;
    lastparagraph:=word_sj.documents.item(1).paragraphs.count;
    word_sj.documents.item(1).paragraphs.item(lastparagraph).range.Paste;
    word_sj.documents.item(1).saveas('第一个文件.doc');
    word_sj.documents.item(1).close;
    Table1.Close;
    Table1.open;
    Table1.Append;
    tblobfield(Table1.FieldByName('xxx')).loadfromfile('第一个文件.doc');
    Table1.Post;
    Table1.Close;
    END;
      

  11.   

    WordDocument.Range.InsertFile(filename,[range],[confirmconversion],[link],attachment])
      

  12.   

    继续直接插入:
    WordDocument.Range.InsertFile('E:\aaa.txt', EmptyParam, EmptyParam, EmptyParam, EmptyParam);
    WordDocument.Range.InsertFile('E:\Shi.txt', EmptyParam, EmptyParam, EmptyParam, EmptyParam);
      

  13.   

    如果采用我所讲的办法,就将:
    word_sj.documents.item(1).saveas('第一个文件.doc');
    换成word_sj.documents.item(1).saveas('第一个文件bak.doc');
    tblobfield(Table1.FieldByName('xxx')).loadfromfile('第一个文件.doc');
    换成tblobfield(Table1.FieldByName('xxx')).loadfromfile('第一个文件bak.doc');
      

  14.   

    如果使用SERVER控件,就使用WordApplication, 将WordDocument换成WordApplication,肯定没问题:WordDocument.Range. 使用 WordApplication.Selection.替换
                                    ----------------TWordApplication控件    WordApplication1.Selection.InsertFile('E:\aaa.txt', EmptyParam, EmptyParam, EmptyParam, EmptyParam);
        WordApplication1.Selection.InsertFile('E:\Shi.txt', EmptyParam, EmptyParam, EmptyParam, EmptyParam);
      

  15.   

    <电脑编程技巧与维护> 杂志 2003年6期开始专门介绍了delphi对word的操作.
    去他们网站上去下载源代码看看.如果看具体的介绍可能只能买杂志了.