得到WORD的作者、页数、名称<br><br>uses<br> Comobj;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>const<br> wdPropertyTitle = $00000001;<br> wdPropertySubject = $00000002;<br> wdPropertyAuthor = $00000003;<br> wdPropertyKeywords = $00000004;<br> wdPropertyComments = $00000005;<br> wdPropertyTemplate = $00000006;<br> wdPropertyLastAuthor = $00000007;<br> wdPropertyRevision = $00000008;<br> wdPropertyAppName = $00000009;<br> wdPropertyTimeLastPrinted = $0000000A;<br> wdPropertyTimeCreated = $0000000B;<br> wdPropertyTimeLastSaved = $0000000C;<br> wdPropertyVBATotalEdit = $0000000D;<br> wdPropertyPages = $0000000E;<br> wdPropertyWords = $0000000F;<br> wdPropertyCharacters = $00000010;<br> wdPropertySecurity = $00000011;<br> wdPropertyCategory = $00000012;<br> wdPropertyFormat = $00000013;<br> wdPropertyManager = $00000014;<br> wdPropertyCompany = $00000015;<br> wdPropertyBytes = $00000016;<br> wdPropertyLines = $00000017;<br> wdPropertyParas = $00000018;<br> wdPropertySlides = $00000019;<br> wdPropertyNotes = $0000001A;<br> wdPropertyHiddenSlides = $0000001B;<br> wdPropertyMMClips = $0000001C;<br> wdPropertyHyperlinkBase = $0000001D;<br> wdPropertyCharsWSpaces = $0000001E;<br>var<br> vWord, vDoc, docBuiltInProps, typeDocBuiltInProps: Variant;<br>begin<br> if not OpenDialog1.Execute then<br> Exit;<br> vWord := CreateOleObject('Word.Application'); //创建Word线程<br> try<br> //打开要操作的文件<br> vDoc := vWord.Documents.Open(OpenDialog1.FileName);<br> docBuiltInProps := vDoc.BuiltInDocumentProperties;<br> memo1.Lines.Add(format('%s : %s', ['页数',<br> vDoc.BuiltInDocumentProperties[wdPropertyPages].Value]));<br> memo1.Lines.Add(format('%s : %s', ['作者',<br> vDoc.BuiltInDocumentProperties[wdPropertyAuthor].Value]));<br> memo1.Lines.Add(format('%s : %s', ['标题',<br> vDoc.BuiltInDocumentProperties[wdPropertyTitle].Value]));<br> finally<br> vDoc.Close(True); //关闭文并保存<br> vWord.Quit(False); //退出Word<br> end;<br>end;