View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
RB Smissaert RB Smissaert is offline
external usenet poster
 
Posts: 2,452
Default Accessing Custom Doc Properties on Closed File

You can do this with DSOFile.dll or try this function:

Function GetFileProperty(vFolder As Variant, _
strFile As String, _
Optional lIndex As Long, _
Optional strItemName As String) As String

Dim i As Long
Dim objShell As Object
Dim objFolder As Object
Dim objFolderItem As Object
Dim arrHeaders(41)

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(vFolder)
Set objFolderItem = objFolder.ParseName(strFile)

If Len(strItemName) 0 Then
For i = 0 To 40
arrHeaders(i) = objFolder.GetDetailsOf(objFolder.Items, i)
If arrHeaders(i) = strItemName Then
lIndex = i
Exit For
End If
Next
End If

GetFileProperty = objFolder.GetDetailsOf(objFolderItem, lIndex)

End Function


Use it like this:

Sub test()

MsgBox GetFileProperty("C:\ExcelFiles\", "MyFile.xls", , "Category")

End Sub


It works on for example text files as well.


RBS


"Barb Reinhardt" wrote in message
...
Is it possible to do this? I am trying to get data out of a team site
and
I have the site mapped. We also have custom document properties for year,
month, etc. I'd like to only open those workbooks that meet a specified
selection. Can this be done, or can we only get the custom document
properties when the workbook is opened. Right now I'm opening every
workbook
and looking at the properties, but I'd like to cut out the open step if
possible.

Thanks,
Barb Reinhardt