Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Job Job is offline
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default 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   Report Post  
Posted to microsoft.public.excel.programming
Job Job is offline
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Post Newfie809 Excel Worksheet Functions 2 October 22nd 09 09:47 PM
my post Help with cell function[_2_] Excel Discussion (Misc queries) 3 October 8th 09 02:31 PM
Further to my other post.... Connie Martin Excel Worksheet Functions 4 March 20th 09 07:56 PM
post Sheryl Excel Discussion (Misc queries) 1 February 13th 06 09:22 PM
Should I generally request "post a poll" when I post a new thread? Joe Miller Excel Discussion (Misc queries) 2 January 7th 06 04:46 PM


All times are GMT +1. The time now is 07:21 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"