如题

解决方案 »

  1.   

    没有问题。修改Document的Table[Idx]的Borders的InsideColor或OutsideColor
    或者Borders[Idx](Border)的Color
      

  2.   

    花了点时间给你作了一个演示。uses
      Word2000;procedure TWMITaskManagerMainForm.ButtonWordClick(Sender: TObject);
    var
      WordApplication: TWordApplication;
      WordDocument: TWordDocument;
      DocInx, oFileName, CfCversions, oReadOnly, AddToRctFiles, PswDocument,
      PswTemplate, oRevert, WPswDocument, WPswTemplate, oFormat, oEncoding, oVisible: OleVariant;
      Idx: Integer;
      Row: Integer;
      Col: Integer;
      _Cell: Cell;
    begin
      WordApplication := TWordApplication.Create(nil);
      WordApplication.Visible := True;
      WordDocument := TWordDocument.Create(nil);  DocInx := 1;
      oFileName := 'c:\test.doc';
      oReadOnly := True;
      CfCversions := EmptyParam;
      AddToRctFiles := EmptyParam;
      PswDocument := EmptyParam;
      PswTemplate := EmptyParam;
      oRevert := EmptyParam;
      WPswDocument := EmptyParam;
      WPswTemplate := EmptyParam;
      oFormat := EmptyParam;
      oEncoding := EmptyParam;
      oVisible := True;  WordApplication.Documents.Open(oFileName, CfCversions, oReadOnly, AddToRctFiles,
                                      PswDocument, PswTemplate, oRevert, WPswDocument,
                                      WPswTemplate, oFormat, oEncoding, oVisible);  WordDocument.ConnectTo(WordApplication.Documents.Item(DocInx));  Idx := 1;  //按列变换表格线不同颜色
      {for Col := 1 to WordDocument.Tables.Item(Idx).Columns.Count do
      begin
        WordDocument.Tables.Item(Idx).Columns.Item(Col).Borders.OutsideColorIndex := Col;
      end; }  //按行变换表格线不同颜色
      {for Row := 1 to WordDocument.Tables.Item(Idx).Rows.Count do
      begin
        WordDocument.Tables.Item(Idx).Rows.Item(Row).Borders.OutsideColorIndex := Row;
      end }  //下面是综合颜色变换 (按单元格)字体颜色、表格线颜色
      {for Idx := 1 to WordDocument.Tables.Count do
      begin
        for Row := 1 to WordDocument.Tables.Item(Idx).Rows.Count do
        begin
          for Col := 1 to WordDocument.Tables.Item(Idx).Columns.Count do
          begin
            _Cell := WordDocument.Tables.Item(Idx).Cell(Row, col);
            _Cell.Borders.OutsideColor := clBlue;
            _Cell.Range.Font.Color := clRed;
          end
        end;
      end;}
    end;
      

  3.   

    实在是太感谢你了!
    你对WORD好有研究,我这边还有个这方面的问题,不知道你能不能帮忙解决一下
    就是如果改变WORD文档里的字体颜色,每个字体颜色都取反的,就是黑的变白的这样?
      

  4.   

    呵呵, 早上起来运动完就有问题来了。
    字体反色:_Cell.Range.Font.Color := RGB(255 -GetRValue(_Cell.Range.Font.Color),
                                  255 -GetGValue(_Cell.Range.Font.Color),
                                  255 -GetBValue(_Cell.Range.Font.Color));
      

  5.   

    呵呵,不是表格里的字体,是整个Word文档的字体?
      

  6.   

    var
      _Color: TColor;......  _Color := WordDocument.Tables.Item(Idx).Range.Font.Color;  WordDocument.Tables.Item(Idx).Range.Font.Color := RGB(255 -GetRValue(_Color),
                                                            255 -GetGValue(_Color),
                                                            255 -GetBValue(_Color));......其实修改单元格每个字体颜色应该更精细, 可以多种色彩。
      

  7.   

    整个文挡一次性修改字体颜色是:WordDocument.Range.Font.Color := ......(RGB(.......))同上我还是建议循环修改。
      

  8.   

    WordDocument.Range.Font.Color := ......(RGB(.......))这句话好象也不对Range好象有个起始选择和结束