objFolder.ParseName Method Not Found

L

Lazzaroni

I am attempting to retrieve the dimensions of an image before I insert the
image into a spreadsheet as a thumbnail so that I can scale the image
accurately.

Dim objShell As New Shell
Dim objFolder As Folder
Dim objFile As ShellFolderItem

Set objFolder = objShell.NameSpace(<path to file>)
Set objFile = objFolder.ParseName(<file name>)

MsgBox objFile.ExtendedProperty("Dimensions")

The above code does not seem to be working because the method "ParseName" is
not found. I have enabled the reference to "Microsoft Shell Controls and
Automation" but still no go.

Does anyone know how to enable ParseName, or have a better way of retrieving
image dimensions?

Thank you.
 
S

Steve Yandl

This is one approach. Note that the dimensions will be returned as width by
height in pixels with " x " as separator.

'--------------------------------------------------

Private Function PictureDimensions(filePath As String) As String

Set FSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Shell.Application")

If Not FSO.FileExists(filePath) Then
PictureDimensions = ""
End If

strParent = FSO.GetParentFolderName(filePath)
strArgFileName = FSO.GetFileName(filePath)
Set objFolder = objShell.Namespace(strParent)

For Each strFileName In objFolder.Items
If objFolder.GetDetailsOf(strFileName, 0) = strArgFileName Then
PictureDimensions = objFolder.GetDetailsOf(strFileName, 26)
End If
Next

Set FSO = Nothing
Set objShell = Nothing

End Function


'--------------------------------------------------

Steve Yandl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top