下面这些从前的资料,你看看吧
给你几个函数:
GetDocPages : 得到文档的总页数;
GetCurrentPage : 得到当前关标所在的页码
GotoNextPage : 移到下一页开始处
GotoFirstPage : 移到第一页开始处
对于你的问题流程是
其中WordApp : TWordApplication, WordDoc : TWordDocument)
GotoFirstPage(WordApp);
插入一些内容;
while GetCurrentPage(WordApp) < GetDocPages(WordDoc) do
begin
GotoNextPage(WordApp);
插入一些内容
end;
上面所说的几个函数代码如下:
// get the document's pages
function TForm1.GetDocPages(WrdDoc : TWordDocument) : integer;
var
ActDoc : Variant;
begin
ActDoc := CreateOleObject('Word.Document');
ActDoc := WrdDoc.DefaultInterface;
result := ActDoc.BuiltInDocumentProperties[wdPropertyPages].Value;
ActDoc := unassigned;
end;
// get current page index
function TForm1.GetCurrentPage(WrdApp : TWordApplication) : integer;
begin
result := WrdApp.Selection.Information[wdActiveEndPageNumber];
end;
// go to next page
procedure TForm1.GotoNextPage(WrdApp: TWordApplication);
begin
WrdApp.Browser.Next;
end;
// go to first page
procedure TForm1.GotoFirstPage(WrdApp: TWordApplication);
var
WdUnit,WdCount,wdExtend : OleVariant;
begin
WdUnit := wdScreen;
wdCount := 10;
wdExtend := EmptyParam;
while true do
if WrdApp.Selection.MoveUp(WdUnit,wdCount,wdExtend) = 0 then break;
end;
另
http://www.delphibbs.com/delphibbs/DispQ.asp?LID=758501
怎样用delphi控制word在页的最后增加一页,然后再写入一些内容