0

我有一个 VBS 列表脚本来列出文件,有不同的日期。所有文件都是 MS Word 文档,但我想要文档属性中的作者(我尝试使用谷歌搜索“作者”属性而不是最佳搜索)。

我在一个文件夹中所有文档的文本列表之后:- 文件名、访问日期、创建日期、修改日期和作者。我希望 VBS 能破解它,但如果有其他解决方案,我愿意接受建议。

On Error Resume Next

Const WINDOW_HANDLE = 0
Const BIF_EDITBOX = &H10
Const BIF_NONEWFOLDER = &H0200
Const BIF_RETURNONLYFSDIRS = &H1

Set objShell = CreateObject("Shell.Application")
Set wshShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")

'**Browse For Folder To Be Processed
strPrompt = "Please select the folder to process."
intOptions = BIF_RETURNONLYFSDIRS + BIF_NONEWFOLDER + BIF_EDITBOX
strTargetPath = wshShell.SpecialFolders("MyDocuments")
strFolderPath = Browse4Folder(strPrompt, intOptions, strTargetPath)

Set objNewFile = objFSO.CreateTextFile(strFolderPath & "\filelist.txt", True)
Set objFolder = objFSO.GetFolder(strFolderPath)
Set objColFiles = objFolder.Files

For Each file In objColFiles
    objNewFile.WriteLine(file.Name)
    objNewFile.WriteLine(file.DateCreated)
    objNewFile.WriteLine(file.DateLastAccessed)
    objNewFile.WriteLine(file.DateLastModified)
Next
objNewFile.Close

'**Browse4Folder Function
Function Browse4Folder(strPrompt, intOptions, strRoot)
    Dim objFolder, objFolderItem

    On Error Resume Next

    Set objFolder = objShell.BrowseForFolder(0, strPrompt, intOptions, strRoot)
    If (objFolder Is Nothing) Then
        Wscript.Quit
    End If
    Set objFolderItem = objFolder.Self
    Browse4Folder = objFolderItem.Path
    Set objFolderItem = Nothing
    Set objFolder = Nothing
End Function
4

1 回答 1

0

您必须检查 Word 应用程序对象的属性。

看看这里例如如何做到这一点。

应该是这样的:

Set oWord = CreateObject("Word.Application")
Set oDoc = oWord.Documents.Open("myWordDocument.doc")
Set sAuthor = oDoc.BuiltInDocumentProperties("Author")
于 2012-09-06T10:37:09.153 回答