Eric Strobel
New Member
- Joined
- Oct 4, 2018
- Messages
- 4
I am trying to be able to insert the path to an image, and have the dimensions and other attributes of the image returned in a cell. I am able to get the dimensions of all the images located in the specified folder when running the macro below:
Sub Dimensions()
Dim sFile As Variant
Dim oShell: Set oShell = CreateObject("Shell.Application")
Dim oDir: Set oDir = oShell.Namespace("C:\Users\estel\Pictures\Saved Pictures")
Dim i As Long
i = 1
For Each sFile In oDir.Items
Cells(i, 1).Value = oDir.GetDetailsOf(sFile, 0)
Cells(i, 2).Value = oDir.GetDetailsOf(sFile, 1)
Cells(i, 3).Value = oDir.GetDetailsOf(sFile, 2)
Cells(i, 4).Value = oDir.GetDetailsOf(sFile, 31)
i = i + 1
Next
MsgBox "Done"
End Sub
The two issues I am having are the following:
1. This code does not use the path located in the desired cell (O12), and requires me to manually change the path through vba.
2. This code lists the desired attributes of all images in the file folder Saved Pictures, when I only want the attributes of the image specified in O12.
I am fairly new to vba so apologize if the solution is simple. Thank you in advance for the help.
Sub Dimensions()
Dim sFile As Variant
Dim oShell: Set oShell = CreateObject("Shell.Application")
Dim oDir: Set oDir = oShell.Namespace("C:\Users\estel\Pictures\Saved Pictures")
Dim i As Long
i = 1
For Each sFile In oDir.Items
Cells(i, 1).Value = oDir.GetDetailsOf(sFile, 0)
Cells(i, 2).Value = oDir.GetDetailsOf(sFile, 1)
Cells(i, 3).Value = oDir.GetDetailsOf(sFile, 2)
Cells(i, 4).Value = oDir.GetDetailsOf(sFile, 31)
i = i + 1
Next
MsgBox "Done"
End Sub
The two issues I am having are the following:
1. This code does not use the path located in the desired cell (O12), and requires me to manually change the path through vba.
2. This code lists the desired attributes of all images in the file folder Saved Pictures, when I only want the attributes of the image specified in O12.
I am fairly new to vba so apologize if the solution is simple. Thank you in advance for the help.