问题:
如果不用DDE如何在word中画出表格线.
用DDE如何在word中能画出表格线,在打印预览时不显示表格线,我查看了word是无边框的,不知道如何加上边框.
在保存word后,如何清空指定word文档的内容. 
以下是我写的代码,不知是不是有问题,请大家帮看一下,小妹在此先谢谢各位了
procedure TForm1.Button4Click(Sender: TObject);var i,m : Integer; fpage,pagea,WordYeMeiRange: olevariant; s: String; doc : Variant;  _Range: OleVariant;  _DefaultTableBehavior, _AutoFitBehavior: OleVariant;begin    Memo.Lines.Clear;    WordApp:= CreateOleObject( 'word.Application ');    doc := WordApp.documents.add;    WordApp.visible := true;    qryuserCount.Close;    qryuserCount.Open;
    qryuser.Close;    qryuser.Open;
      with qryuser do      begin        if not qryuser.IsEmpty then        begin          m :=0;          Memo.Lines.Add( '日期        时间    开嘱医生        执行科室        所在科室 ');          while not Eof do          begin              if m  >41 then              begin                m :=0;                Memo.Lines.Add( '日期 时间 开嘱医生 执行科室 所在科室 ');              end;              s :=fieldbyName( 'userno ').AsString + '  '+              fieldbyName( 'username ').AsString + '  '+              fieldbyName( 'password ').AsString + '  '+              fieldbyName( 'ismgr ').AsString + '  '+              fieldbyName( 'isvalid ').AsString;              Memo.Lines.Add(s);              m := m + 1;            Next;          end;
        end;      end;      doc.range.text := Memo.Text;      WordApp.Selection.WholeStory; // 全选
    RunMacro(PChar( '[EditSelectAll] ')) ;    RunMacro(PChar( '[TableInsertTable] ')) ;    sleep(1000);    WordApp.documents.Item(1).Tables.Item(1).Columns.Item(1).width := 40;    WordApp.documents.Item(1).Tables.Item(1).Columns.Item(2).width := 50;    WordApp.documents.Item(1).Tables.Item(1).Columns.Item(3).width := 150;    WordApp.documents.Item(1).Tables.Item(1).Columns.Item(4).width := 75;    WordApp.documents.Item(1).Tables.Item(1).Columns.Item(5).width := 75;      //RunMacro(PChar( '[FileExit] ')) ;    //加入页眉    WordApp.ActiveWindow.ActivePane.View.SeekView :=wdSeekCurrentPageHeader ;    WordApp.Selection.ParagraphFormat.Alignment := wdAlignParagraphCenter;    WordApp.Selection.InsertAfter( '石家庄市人民医院 ');    WordApp.Selection.InsertAfter(#13);    //WordApp.ActiveWindow.Selection.Font.Bold := wdToggle;//粗体    WordApp.ActiveWindow.Selection.Font.Size:=14;    WordApp.Selection.InsertAfter( '长   期   医   嘱   单 ');    WordApp.ActiveWindow.Selection.Font.Bold := wdToggle;//粗体    WordApp.ActiveWindow.Selection.Font.Size:=16;    WordApp.Selection.InsertAfter(#13);    WordApp.Selection.InsertAfter( '姓名:张五一  性别: 男         病区:          病室:        床号:          住院号:0095196 ');    WordApp.ActiveWindow.ActivePane.View.SeekView:=wdSeekMainDocument;
      fpage := True;      pagea := wdAlignPageNumberCenter;      WordApp.activedocument.sections.item(1).Footers.item(1).PageNumbers.add(pagea,fpage);end;procedure TForm1.RunMacro(Macro:pChar);var  pMacro:array[0..80] of Char;begin  DDEClient.SetLink( 'Winword ', 'System ');{设置连接}  DDEClient.OpenLink;{按设置打开连接}  StrPCopy(pMacro,Macro);  if Not DDEClient.ExecuteMacro(pMacro,false) then{执行宏命令}  ShowMessage( 'Unable to Execute Macro ');  DDEClient.CloseLink;{断开连接}end;

解决方案 »

  1.   

    WordApp.documents.Item(1).Tables.Item(1).Borders.Enable = wdLineStyleDashSmallGap;
    查VBA得到的,没试过,你试一下,是设置表格的边框为虚线的,如果你要是添加的表格,有一个参数可以设置的。
      

  2.   

    好,我现试一下,先谢谢了.
    to Bear_hx
    ¨有一个参数可以设置的¨
    怎么设置呢???
      

  3.   

    好,我现试一下,先谢谢了.
    to Bear_hx
    ¨有一个参数可以设置的¨
    怎么设置呢???
      

  4.   

    Bear_hx你真是个高人,我试过了,是可以的。根据你给的linestyle的值,我到C:\Program Files\Borland\Delphi6\Ocx\Servers\word2000.pas中查找到各种边线的样式
      

  5.   

      wdLineStyleNone = $00000000;  wdLineStyleSingle = $00000001;  wdLineStyleDot = $00000002;  wdLineStyleDashSmallGap = $00000003;  wdLineStyleDashLargeGap = $00000004;  wdLineStyleDashDot = $00000005;  wdLineStyleDashDotDot = $00000006;  wdLineStyleDouble = $00000007;  wdLineStyleTriple = $00000008;  wdLineStyleThinThickSmallGap = $00000009;  wdLineStyleThickThinSmallGap = $0000000A;  wdLineStyleThinThickThinSmallGap = $0000000B;  wdLineStyleThinThickMedGap = $0000000C;  wdLineStyleThickThinMedGap = $0000000D;  wdLineStyleThinThickThinMedGap = $0000000E;  wdLineStyleThinThickLargeGap = $0000000F;  wdLineStyleThickThinLargeGap = $00000010;  wdLineStyleThinThickThinLargeGap = $00000011;  wdLineStyleSingleWavy = $00000012;  wdLineStyleDoubleWavy = $00000013;  wdLineStyleDashDotStroked = $00000014;  wdLineStyleEmboss3D = $00000015;  wdLineStyleEngrave3D = $00000016;  wdLineStyleOutset = $00000017;  wdLineStyleInset = $00000018;