Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Re-Post Anyone know how to do this?
I'm trying to find *.jpg in a folder. As I iterate through the list, I
would like to capture the name of the file, and the dimensions of the file and paste the values into an Excel sheet. Anyone know how this is done? ANY help is appreciated! Cheers, Job |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Re-Post Anyone know how to do this?
You can use the the FileSystemObject for this. Here's some sample code.
Option Explicit Option Compare Text Sub GetFileNamesAndSizes() Dim File_ As File Dim FileList As Files Dim FSO As FileSystemObject Dim FileInfo() As Variant Dim N As Long Set FSO = CreateObject("Scripting.FileSystemObject") Set FileList = FSO.GetFolder(CurDir$()).Files ReDim FileInfo(1 To FileList.Count, 1 To 2) N = 0 For Each File_ In FileList If File.Name Like "*.jpg" Then N = N + 1 FileInfo(N, 1) = File_.Name FileInfo(N, 2) = File_.Size End If Next File_ Range("A1:B1").Value = Array("JPG Files", "Size") Range("A2").Resize(N, 2).Value = FileInfo() End Sub On Sat, 26 Jul 2003 18:46:45 -0500, "Job" wrote: I'm trying to find *.jpg in a folder. As I iterate through the list, I would like to capture the name of the file, and the dimensions of the file and paste the values into an Excel sheet. Anyone know how this is done? ANY help is appreciated! Cheers, Job |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Re-Post Anyone know how to do this?
Thanks Myrna! I actually just finished creating a little sub that uses the
functions provided at http://www.4guysfromrolla.com/webtech/050300-1.shtml If anyone is interested I'll post what I did with it. This can essentially be used to get the dims of your images for a dynamic web page or something..at least that is what I'm using it for. I have the code looking for specifically named images--those that end in "sm.jpg", but obviously you could change that or take it out if you want every image. Cheers! Sub GetMyDims() Set objFSO = CreateObject("Scripting.FileSystemObject") Set objF = objFSO.GetFolder("C:\Images\") Set objFC = objF.Files p = 1 For Each f1 In objFC If gfxSpex(f1.Path, w, h, c, strType) = True Then If Right(f1.Name, 6) = "sm.jpg" Then p = p + 1 myname = "A" & p mywidth = "B" & p myheight = "C" & p Range(myname).Select ActiveCell.FormulaR1C1 = f1.Name Range(myheight).Select ActiveCell.FormulaR1C1 = h Range(mywidth).Select ActiveCell.FormulaR1C1 = w End If End If Next Set objFC = Nothing Set objF = Nothing Set objFSO = Nothing End Sub "Myrna Larson" wrote in message ... You can use the the FileSystemObject for this. Here's some sample code. Option Explicit Option Compare Text Sub GetFileNamesAndSizes() Dim File_ As File Dim FileList As Files Dim FSO As FileSystemObject Dim FileInfo() As Variant Dim N As Long Set FSO = CreateObject("Scripting.FileSystemObject") Set FileList = FSO.GetFolder(CurDir$()).Files ReDim FileInfo(1 To FileList.Count, 1 To 2) N = 0 For Each File_ In FileList If File.Name Like "*.jpg" Then N = N + 1 FileInfo(N, 1) = File_.Name FileInfo(N, 2) = File_.Size End If Next File_ Range("A1:B1").Value = Array("JPG Files", "Size") Range("A2").Resize(N, 2).Value = FileInfo() End Sub On Sat, 26 Jul 2003 18:46:45 -0500, "Job" wrote: I'm trying to find *.jpg in a folder. As I iterate through the list, I would like to capture the name of the file, and the dimensions of the file and paste the values into an Excel sheet. Anyone know how this is done? ANY help is appreciated! Cheers, Job |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Re-Post Anyone know how to do this?
The tricky part is getting the dimensions of the JPG file.
I studied the matter and concluded that it was more complex than I wanted to undertake at the moment. The specification is extremely obtuse. David Gray P6 Consulting http://www.p6c.com You are more important than any technology we may employ. -----Original Message----- I'm trying to find *.jpg in a folder. As I iterate through the list, I would like to capture the name of the file, and the dimensions of the file and paste the values into an Excel sheet. Anyone know how this is done? ANY help is appreciated! Cheers, Job . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Post | Excel Worksheet Functions | |||
my post | Excel Discussion (Misc queries) | |||
Further to my other post.... | Excel Worksheet Functions | |||
post | Excel Discussion (Misc queries) | |||
Should I generally request "post a poll" when I post a new thread? | Excel Discussion (Misc queries) |