做了个模板,其中有一个大表格,占两页。我用tables(1).range.copy复制,然后要怎么paste才能让新粘贴的表格另起一页啊?现在出来的效果总是和第一个表格合并。我快被ms的range搞疯了!求高人解救!!!
解决方案 »
- CreateMutex与CreateSemaphore的问题
- 关于线程终止问题,急用!!
- 在DBGRID中,以便对selectedrows进行操作。在程序中如何解决将几条记录设为被选中状态。
- 放分求教:第一次安装控件,不会弄,ACReport1.81~~~??
- 有谁用过Formula one做个报表开发的?介绍有分。
- 大家来看看人民教育出版社的书,如此粗劣!义务教育教材竟然雷同!!!---请斑竹不要删除好么
- 一条SQL查询语句的应用.请各位看过来
- 哪里有object pacal的编译器下载哪?
- 俺做了一个EXE合并程序,可以不改变原文件图标!
- 如何引用VBA中的函数
- 创建一个线程需要几个参数?
- Delphi2007: 关于tab控件的使用方发!
TWord = class
private
WordApp: TWordApplication;
procedure InsertSectionBreak;
public
destructor Destroy; override;
function Open(FileName: String): Boolean;
procedure CopyTable;
procedure PasteTable;
procedure SetTableText(TableNum, Row, Column: Integer; Text: String);
procedure InsertRows(RowCount: Integer);
procedure MoveEnd;
procedure MoveBack;
procedure MoveRight;
procedure DelRow(Row: Integer);
procedure Save(FileName: String);
end;function IsExistsProcess(ProcessName: String): Boolean;implementation{ TWord }procedure TWord.CopyTable;
begin
WordApp.ActiveDocument.Tables.Item(1).Select;
WordApp.Selection.Copy;
end;procedure TWord.DelRow(Row: Integer);
begin
//self.WordApp.ActiveDocument.Tables.Item(TableNum).Rows.Last.Delete;
end;destructor TWord.Destroy;
//var
// Saved: OleVariant;
begin
//Saved:= false;
self.WordApp.Disconnect;
//self.WordApp.Quit(Saved);
self.WordApp.Quit;
self.WordApp.Free;
inherited;
end;procedure TWord.InsertRows(RowCount: Integer);
var
OleVar: OleVariant;
begin
OleVar:= RowCount;
self.WordApp.Selection.InsertRows(OleVar);
//WordDoc.Application.Selection.InsertRows(OleVar);
end;procedure TWord.InsertSectionBreak;
var
SectionBreak: OleVariant;
begin
SectionBreak:= wdSectionBreakNextPage;
self.WordApp.Selection.InsertBreak(SectionBreak);
//self.WordApp.Selection.Sections.Last
with self.WordApp.Selection.Sections.Last.Headers.Item(1).PageNumbers do
begin
NumberStyle:= wdPageNumberStyleArabic;
HeadingLevelForChapter:= 0;
IncludeChapterNumber:= false;
ChapterPageSeparator:= wdSeparatorHyphen;
RestartNumberingAtSection:= true;
StartingNumber:= 1;
end;
end;procedure TWord.MoveBack;
var
ovUnit, ovCount, ovExtend: OleVariant;
begin
ovCount:= 1;
ovUnit := wdCharacter;
self.WordApp.Selection.MoveLeft(ovUnit, ovCount, ovExtend);
end;procedure TWord.MoveEnd;
var
ovUnit: OleVariant;
begin
ovUnit:= wdStory;
self.WordApp.Selection.EndKey(ovUnit, EmptyParam);
end;procedure TWord.MoveRight;
var
ovUnit, ovCount, ovExtend: OleVariant;
begin
ovCount:= 1;
ovUnit := wdCharacter;
self.WordApp.Selection.MoveRight(ovUnit, ovCount, ovExtend);
end;function TWord.Open(FileName: String): Boolean;
var
WordFileName: OleVariant;
begin
Result:= true;
WordFileName:= FileName;
try
self.WordApp:= TWordApplication.Create(nil);
self.WordApp.Visible := false;
self.WordApp.Documents.Open(WordFileName, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam);
except
Result:= false;
end;
end;procedure TWord.PasteTable;
begin
InsertSectionBreak;
self.WordApp.Selection.Paste;
end;procedure TWord.Save(FileName: String);
var
WordFileName: OleVariant;
begin
if FileExists(FileName) then DeleteFile(FileName);
WordFileName:= FileName;
self.WordApp.ActiveDocument.SaveAs(WordFileName, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam);
end;procedure TWord.SetTableText(TableNum, Row, Column: Integer; Text: String);
begin
self.WordApp.ActiveDocument.Tables.Item(TableNum).
Cell(Row, Column).Range.Text:= Text;
end;