Issue with GetDetailsOf

sfazam

New Member
Joined
Oct 26, 2014
Messages
10
Hi,
I am using following code to get size of Image i.e. 1024 x 768.

This code is returning only "Dimensions" keyword.
Code:
Function PictureDimensions(filePath As String) As String


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


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


PictureDimensions = objFolder.GetDetailsOf(strParent, 31)


End Function

Any suggestion from experts?
 
Last edited by a moderator:
Try:
Code:
PictureDimensions = objFolder.GetDetailsOf(objFolder.Items.item(strArgFileName), 31)
Please post code inside CODE tags.
 
Upvote 0
Hi,

I am trying to loop through all files in multiple subfolders with this sub and I believe I am having a similar problem as the OP but I'm not sure where to exactly implement the changes with my added For loop and IF statement.

My code works fine when I hardcode the actual filepath, but I am running into an issue when I use UWfolder(i) as a string.

Once I reach the For each loop I get the error "Object variable or With block variable not set." Sorry for the old thread bump but any help is greatly appreciated!


Code:
Sub Example2()
Dim FileName As Object
Dim objShell As Object
Dim objFolder As Object
Dim strList As String
Dim strPath As String
Dim strFileName As String
Dim xx As String, yy As String
xx = "Renewal Retention"
yy = Year(Now) - 1 & " 02"
Dim i As Integer
Dim UWfolder(1 To 5) As String
    UWfolder(1) = "[URL="file://\\MyDocuments\TestPath\1\"]\\MyDocuments\TestPath\1\[/URL]"
    UWfolder(2) = "[URL="file://\\MyDocuments\TestPath\2\"]\\MyDocuments\TestPath\2\[/URL]"
    UWfolder(3) = "[URL="file://\\MyDocuments\TestPath\3\"]\\MyDocuments\TestPath\3\[/URL]"
    UWfolder(4) = "[URL="file://\\MyDocuments\TestPath\4\"]\\MyDocuments\TestPath\4\[/URL]"
    UWfolder(5) = "[URL="file://\\MyDocuments\TestPath\5\"]\\MyDocuments\TestPath\5\[/URL]"
For i = 1 To 5
    
    strPath = UWfolder(i)
    Set objShell = CreateObject("Shell.Application")
    Set objFolder = objShell.Namespace(UWfolder(i)) 'you can't use the string variable here, must put literal value
    
    
    For Each FileName In objFolder.items 'cycle through all files found in strPath
            strFileName = objFolder.getdetailsof(FileName, 0)
                
            If InStr(1, strFileName, xx) Then
                If InStr(1, strFileName, yy) Then
                    ' do nothing
                    Else:
                    MsgBox "File will be deleted"
                End If
            End If
            
    Next FileName
Next i
 
End Sub
 
Upvote 0
The Namespace argument must be a Variant, therefore:
Code:
Set objFolder = objShell.Namespace(CVar(UWfolder(i)))
or declare the UWfolder array as Variant.
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top