香港新浪網 MySinaBlog
« 上一篇 | 下一篇 »
Emily | 4th Jan 2006, 21:46 PM | Office Application | (3754 Reads)

使用 Dsofile.dll 閱讀 / 更改 MS Office 文件資料

好處不需要打開文件

Ref: 什么是 Dsofile?

Ref: Dsofile: The Untold Story

Microsoft Developer Support OLE File Property Reader 2.0 Sample 下載

下載安裝 , 安裝夾內有 FilePropDemoVB6.exe (試執行) , dsofile.dll, VB Source code。

複製 dsofile.dll 到 Windows System 內

執行 regsvr32 (Windows_System_path)dsofile.dll

'

' Set reference to DSO OLE Document Properties Reader 2.0
'
Sub MSOffice_DocumentProperties_DSO()
Dim FileName As String
Dim DSO As DSOFile.OleDocumentProperties
Set DSO = New DSOFile.OleDocumentProperties
FileName = "C:Emily.doc"
DSO.Open sfilename:=FileName
Debug.Print DSO.SummaryProperties.ApplicationName
Debug.Print DSO.SummaryProperties.Subject
Debug.Print DSO.SummaryProperties.Category
Debug.Print DSO.SummaryProperties.Company
Debug.Print DSO.SummaryProperties.Keywords
Debug.Print DSO.SummaryProperties.Manager
Debug.Print DSO.SummaryProperties.LastSavedBy
' Modify Last Saved by
DSO.SummaryProperties.LastSavedBy = "Emily"
DSO.Save
' Show modification
Debug.Print DSO.SummaryProperties.LastSavedBy
' Add custom property
DSO.CustomProperties.Add "My Cats", "Happy and BeeBee"
DSO.Save
' Show added custom property
Debug.Print DSO.CustomProperties.Item("My Cats").Value
' Remove custom property
DSO.CustomProperties.Item("My Cats").Remove
DSO.Save
Debug.Print DSO.SummaryProperties.WordCount
Debug.Print DSO.SummaryProperties.PageCount
Debug.Print DSO.SummaryProperties.ParagraphCount
Debug.Print DSO.SummaryProperties.LineCount
Debug.Print DSO.SummaryProperties.CharacterCount
Debug.Print DSO.SummaryProperties.CharacterCountWithSpaces
Debug.Print DSO.SummaryProperties.ByteCount
Debug.Print DSO.SummaryProperties.PresentationFormat
Debug.Print DSO.SummaryProperties.SlideCount
Debug.Print DSO.SummaryProperties.NoteCount
Debug.Print DSO.SummaryProperties.HiddenSlideCount
Debug.Print DSO.SummaryProperties.MultimediaClipCount
Debug.Print DSO.SummaryProperties.DateCreated
Debug.Print DSO.SummaryProperties.DateLastPrinted
Debug.Print DSO.SummaryProperties.DateLastSaved
Debug.Print DSO.SummaryProperties.TotalEditTime
Debug.Print DSO.SummaryProperties.Template
Debug.Print DSO.SummaryProperties.RevisionNumber
Debug.Print DSO.SummaryProperties.Version
Debug.Print DSO.SummaryProperties.SharedDocument
DSO.Close
End Sub
'
mySinaBlog 不支援反斜線,反斜線現用全形\取代 ,請改回。

 
 
Last update: 19 Jan 2006