unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Comobj;
const
wdPropertyTitle = $00000001;
wdPropertySubject = $00000002;
wdPropertyAuthor = $00000003;
wdPropertyKeywords = $00000004;
wdPropertyComments = $00000005;
wdPropertyTemplate = $00000006;
wdPropertyLastAuthor = $00000007;
wdPropertyRevision = $00000008;
wdPropertyAppName = $00000009;
wdPropertyTimeLastPrinted = $0000000A;
wdPropertyTimeCreated = $0000000B;
wdPropertyTimeLastSaved = $0000000C;
wdPropertyVBATotalEdit = $0000000D;
wdPropertyPages = $0000000E;
wdPropertyWords = $0000000F;
wdPropertyCharacters = $00000010;
wdPropertySecurity = $00000011;
wdPropertyCategory = $00000012;
wdPropertyFormat = $00000013;
wdPropertyManager = $00000014;
wdPropertyCompany = $00000015;
wdPropertyBytes = $00000016;
wdPropertyLines = $00000017;
wdPropertyParas = $00000018;
wdPropertySlides = $00000019;
wdPropertyNotes = $0000001A;
wdPropertyHiddenSlides = $0000001B;
wdPropertyMMClips = $0000001C;
wdPropertyHyperlinkBase = $0000001D;
wdPropertyCharsWSpaces = $0000001E;
type
TForm1 = class(TForm)
Button1: TButton;
OpenDialog1: TOpenDialog;
Memo1: TMemo;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
vWord, vDoc, docBuiltInProps, typeDocBuiltInProps: Variant;
begin
if not OpenDialog1.Execute then Exit;
vWord := CreateOleObject('PowerPoint.Application'); //创建Word线程 try //打开要操作的文件
vDoc := vWord.Documents.Open(OpenDialog1.FileName);
docBuiltInProps := vDoc.BuiltInDocumentProperties;
memo1.Lines.Add(format('%s : %s', ['页数', vDoc.BuiltInDocumentProperties[wdPropertyPages].Value]));
memo1.Lines.Add(format('%s : %s', ['作者', vDoc.BuiltInDocumentProperties[wdPropertyAuthor].Value]));
memo1.Lines.Add(format('%s : %s', ['标题', vDoc.BuiltInDocumentProperties[wdPropertyTitle].Value]));
vDoc.Close(True); //关闭文并保存
vWord.Quit(False); //退出Word end
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
RenameFile('c:/1.doc','c:/2.doc');
end;
end.