I am trying to find the dimensions of some photos on my computer as part of an automatic PowerPoint presentation. As I attempt to make it more automatic, I have run into this problem.
in the line:
Set objFolder = objShellApp.Namespace(strFolder)
objFolder fails and remains at Nothing. However, if a replace the variable strFolder with the actual string value I defined, it actually works perfectly. But I can find a way to make the ObjShellApp.Namespace method accept a string variable. I have a temporary work-around, but would still like to make the path name a string variable.
Is there a secret to make Namespace parameter accept a string variable? Is there another way to do this?
From your forum, and others, I have this routine as a starting point:
Sub Tester1()
Dim strFolder As String
Dim strFile As String
Dim objShellApp As Object
Dim objFolder As Object
Dim objFolderItem As Object
Dim i As Long
strFolder = "C:\Users\Mark\Documents\User"
strFile = "Test.gif"
Set objShellApp = CreateObject("Shell.Application")
Set objFolder = objShellApp.Namespace(strFolder)
Set objFolderItem = objFolder.ParseName(strFile)
Dim arrHeader As String
arrHeader = objFolder.GetDetailsOf(objFolder.Items, 31)
MsgBox "31" & vbTab & arrHeader _
& ": " & objFolder.GetDetailsOf(objFolderItem, 31)
End Sub
I am in Excel 2013, Win10. I am using "Microsoft Scripting Runtime" and "Microsoft Shell Controls and Automation" references.
Marcus
in the line:
Set objFolder = objShellApp.Namespace(strFolder)
objFolder fails and remains at Nothing. However, if a replace the variable strFolder with the actual string value I defined, it actually works perfectly. But I can find a way to make the ObjShellApp.Namespace method accept a string variable. I have a temporary work-around, but would still like to make the path name a string variable.
Is there a secret to make Namespace parameter accept a string variable? Is there another way to do this?
From your forum, and others, I have this routine as a starting point:
Sub Tester1()
Dim strFolder As String
Dim strFile As String
Dim objShellApp As Object
Dim objFolder As Object
Dim objFolderItem As Object
Dim i As Long
strFolder = "C:\Users\Mark\Documents\User"
strFile = "Test.gif"
Set objShellApp = CreateObject("Shell.Application")
Set objFolder = objShellApp.Namespace(strFolder)
Set objFolderItem = objFolder.ParseName(strFile)
Dim arrHeader As String
arrHeader = objFolder.GetDetailsOf(objFolder.Items, 31)
MsgBox "31" & vbTab & arrHeader _
& ": " & objFolder.GetDetailsOf(objFolderItem, 31)
End Sub
I am in Excel 2013, Win10. I am using "Microsoft Scripting Runtime" and "Microsoft Shell Controls and Automation" references.
Marcus