T
TENTODBV
Unregistered / Unconfirmed
GUEST, unregistred user!
我用Delphi写的一个程序,要实现对WORD文档的操作,其中一个要实现的功能是在指定的位置插入文档的总页数。文档中我插入了一个名为bmPages的书签,用来指定插入总页数的位置。
var
i,count:integer;
Word_Handle,Doc_Handle:OleVariant;
BookMark_Name:string;
vFileName,vTemplatelevariant;
vFilename:=ExtractFilePath(Application.ExeName)+'TEMP.doc';
try
Word_Handle:=CreateOleObject('Word.Application');
except
end;
vTemplate:=ExtractFilePath(Application.ExeName)+'Test.doc';
Word_Handle.Visible:=True;
Doc_Handle:=Word_Handle.Documents.Add(Template:=vTemplate,NewTemplate:=False);
BookMark_Name:='bmPages';
//count:=Word_Handle.BuiltInDocumentProperties(wdPropertyPages);
//count:=Word_Handle.Application.Selection.Information(wdNumberOfPagesInDocument);
//我不知道该如何计算页数count
//请教怎样可以求得页数,并保存到count
Doc_Handle.Application.Selection.goto(What:=wdGoToBookmark,Name:=BookMark_Name);
Doc_Handle.Application.Selection.TypeText(IntToStr(count));
var
i,count:integer;
Word_Handle,Doc_Handle:OleVariant;
BookMark_Name:string;
vFileName,vTemplatelevariant;
vFilename:=ExtractFilePath(Application.ExeName)+'TEMP.doc';
try
Word_Handle:=CreateOleObject('Word.Application');
except
end;
vTemplate:=ExtractFilePath(Application.ExeName)+'Test.doc';
Word_Handle.Visible:=True;
Doc_Handle:=Word_Handle.Documents.Add(Template:=vTemplate,NewTemplate:=False);
BookMark_Name:='bmPages';
//count:=Word_Handle.BuiltInDocumentProperties(wdPropertyPages);
//count:=Word_Handle.Application.Selection.Information(wdNumberOfPagesInDocument);
//我不知道该如何计算页数count
//请教怎样可以求得页数,并保存到count
Doc_Handle.Application.Selection.goto(What:=wdGoToBookmark,Name:=BookMark_Name);
Doc_Handle.Application.Selection.TypeText(IntToStr(count));