Iska
05-06-2013, 11:29
как добавить вывод автора последних изменений ? »
firstarey, нет такого свойства. Может быть просто «Автор».
Если а) данное свойство поддерживается документом и б) если Проводник имеет доступ к этому свойству, то можно попробовать.
Вот пример получения значения свойства:
Option Explicit
WScript.Echo GetProperty("E:\Песочница\0264\марк.xlsx", "Автор")
WScript.Quit 0
'=============================================================================
'=============================================================================
Function GetProperty(strPath, strProperty)
Dim objFile
Dim objFolder
Dim objFolderItem
Dim intPropertyNumber
With WScript.CreateObject("Scripting.FileSystemObject")
If Not .FileExists(strPath) Then
WScript.Echo "Can't find file [" & strPath & "]."
Exit Function
End If
Set objFile = .GetFile(strPath)
End With
With WScript.CreateObject("Shell.Application")
Set objFolder = .NameSpace(objFile.ParentFolder.Path)
If Not objFolder Is Nothing Then
Set objFolderItem = objFolder.ParseName(objFile.Name)
If Not objFolderItem Is Nothing Then
intPropertyNumber = GetPropertyNumberByName(strProperty)
If IsEmpty(intPropertyNumber) Then
WScript.Echo "Can't find property name [" & strProperty & "]."
Exit Function
End If
GetProperty = objFolder.GetDetailsOf(objFolderItem, intPropertyNumber)
Else
WScript.Echo "Can't parse file name [" & objFile.Name & "]."
End If
Else
WScript.Echo "Can't get folder [" & objFile.ParentFolder.Path & "]."
End If
End With
End Function
'=============================================================================
'=============================================================================
Function GetPropertyNumberByName(strProperty)
Dim objFolder
Dim i
With WScript.CreateObject("Shell.Application")
Set objFolder = .NameSpace("shell:System")
If Not objFolder Is Nothing Then
For i = 0 To 2^8 - 1
If LCase(objFolder.GetDetailsOf(, i)) = LCase(strProperty) Then
GetPropertyNumberByName = i
Exit For
End If
Next
End If
End With
End Function
'=============================================================================
firstarey, нет такого свойства. Может быть просто «Автор».
Если а) данное свойство поддерживается документом и б) если Проводник имеет доступ к этому свойству, то можно попробовать.
Вот пример получения значения свойства:
Option Explicit
WScript.Echo GetProperty("E:\Песочница\0264\марк.xlsx", "Автор")
WScript.Quit 0
'=============================================================================
'=============================================================================
Function GetProperty(strPath, strProperty)
Dim objFile
Dim objFolder
Dim objFolderItem
Dim intPropertyNumber
With WScript.CreateObject("Scripting.FileSystemObject")
If Not .FileExists(strPath) Then
WScript.Echo "Can't find file [" & strPath & "]."
Exit Function
End If
Set objFile = .GetFile(strPath)
End With
With WScript.CreateObject("Shell.Application")
Set objFolder = .NameSpace(objFile.ParentFolder.Path)
If Not objFolder Is Nothing Then
Set objFolderItem = objFolder.ParseName(objFile.Name)
If Not objFolderItem Is Nothing Then
intPropertyNumber = GetPropertyNumberByName(strProperty)
If IsEmpty(intPropertyNumber) Then
WScript.Echo "Can't find property name [" & strProperty & "]."
Exit Function
End If
GetProperty = objFolder.GetDetailsOf(objFolderItem, intPropertyNumber)
Else
WScript.Echo "Can't parse file name [" & objFile.Name & "]."
End If
Else
WScript.Echo "Can't get folder [" & objFile.ParentFolder.Path & "]."
End If
End With
End Function
'=============================================================================
'=============================================================================
Function GetPropertyNumberByName(strProperty)
Dim objFolder
Dim i
With WScript.CreateObject("Shell.Application")
Set objFolder = .NameSpace("shell:System")
If Not objFolder Is Nothing Then
For i = 0 To 2^8 - 1
If LCase(objFolder.GetDetailsOf(, i)) = LCase(strProperty) Then
GetPropertyNumberByName = i
Exit For
End If
Next
End If
End With
End Function
'=============================================================================