J
Jack Leach
I'm using some code to return an array of file properties:
With CreateObject("Shell.Application").NameSpace...
I'm wondering if it needs to be closed/destroyed somehow after I'm done with
it, as one would with an object? This is a new territory for me.
Thanks,
(the code, which seems to works well...)
Public Function TestProps() As String
Dim ret As Variant
ret = FileGetProperties("D:\something.jpg")
TestProps = ret(2)
End Function
'==============================================================================
' FileGetProperties
'
' Adapted (copied) from Michael Pierron
' http://www.pcreview.co.uk/forums/thread-1862574.php
'-----------------------
Public Function FileGetProperties(sfile As String) As Variant
On Error GoTo Err_Proc
Dim ret(34) As String
'==================
Dim i As Integer
Dim T As String
'==================
With CreateObject("Shell.Application").Namespace(Left( _
sfile, lPosition(sfile, "\") - 1))
For i = 0 To 34
T = .GetDetailsOf(.parsename(Dir(sfile)), i)
If Len(T) Then
ret(i) = .GetDetailsOf(.Items, i) & ":" & T
Debug.Print ret(i)
End If
Next i
End With
'==================
Exit_Proc:
FileGetProperties = ret
Exit Function
Err_Proc:
If cSYSDISPERR Then MsgBox "Error!" & vbCrLf & _
Str(Err.Number) & ": " & Err.Description, _
vbCritical, "Library Error!"
Resume Exit_Proc
Resume
End Function
Private Function lPosition%(Chain$, Char$)
'Dependant of FileGetProperties
Dim iPos%
Do
iPos = InStr(lPosition + 1, Chain, Char, 1)
If iPos Then lPosition = iPos Else Exit Do
Loop
End Function
--
Jack Leach
www.tristatemachine.com
"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
With CreateObject("Shell.Application").NameSpace...
I'm wondering if it needs to be closed/destroyed somehow after I'm done with
it, as one would with an object? This is a new territory for me.
Thanks,
(the code, which seems to works well...)
Public Function TestProps() As String
Dim ret As Variant
ret = FileGetProperties("D:\something.jpg")
TestProps = ret(2)
End Function
'==============================================================================
' FileGetProperties
'
' Adapted (copied) from Michael Pierron
' http://www.pcreview.co.uk/forums/thread-1862574.php
'-----------------------
Public Function FileGetProperties(sfile As String) As Variant
On Error GoTo Err_Proc
Dim ret(34) As String
'==================
Dim i As Integer
Dim T As String
'==================
With CreateObject("Shell.Application").Namespace(Left( _
sfile, lPosition(sfile, "\") - 1))
For i = 0 To 34
T = .GetDetailsOf(.parsename(Dir(sfile)), i)
If Len(T) Then
ret(i) = .GetDetailsOf(.Items, i) & ":" & T
Debug.Print ret(i)
End If
Next i
End With
'==================
Exit_Proc:
FileGetProperties = ret
Exit Function
Err_Proc:
If cSYSDISPERR Then MsgBox "Error!" & vbCrLf & _
Str(Err.Number) & ": " & Err.Description, _
vbCritical, "Library Error!"
Resume Exit_Proc
Resume
End Function
Private Function lPosition%(Chain$, Char$)
'Dependant of FileGetProperties
Dim iPos%
Do
iPos = InStr(lPosition + 1, Chain, Char, 1)
If iPos Then lPosition = iPos Else Exit Do
Loop
End Function
--
Jack Leach
www.tristatemachine.com
"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)