View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Juan Sanchez Juan Sanchez is offline
external usenet poster
 
Posts: 19
Default Loop thru All Files in a Folder



Ok, after several attempts this seems to work:

'==========================
Option Explicit
Sub ReNameAll()
Dim FS As Object
Dim MyFolder As String
Dim MyName As String
Dim i As Integer
MyFolder = "C:\Documents and
Settings\Juan\Escritorio\Juan\"
Set FS = Application.FileSearch
With FS
..LookIn = MyFolder
..Filename = "*"
End With
If FS.Execute 0 Then
For i = 1 To FS.FoundFiles.Count
MyName = FS.FoundFiles(i)
Name MyName As MyFolder & Format(i, "000") & ".doc"
Next i
Else
End If
End Sub
'==========================

Still, it doesn't looks like the last time and for sure
last time it was much more simpler... not that this one
is complicated... but at least it had less lines...

Any thoughts...any one....?

Cheers
Juan



-----Original Message-----
Hi All,

I've been here for this same threath a long time ago, I
just can't seem to remember how to do the following and
some how I've lost my macro.

I have a macro that calls each of the files in a path

and
extracts some of the fields in it. The file opened is a
*.doc and the macro does some text to column stuff and

so
forth so that I get the values from the report.

The reports name that my macro calls are 1.doc,
2.doc, ..., n.doc but this is not the name with which I
receive the reports, the name is given by the measuring
machine and is composed by part number, date, time etc...

After my post a long time ago, I was able to write a

macro
that loops thru all the files in a given folder and
renames them into the usable 1.doc, 2.doc way and now i
don't have it.

Can anyone help me find the right code for this task???

I have 500+ files to rename, just to get 3 little

numbers
from each...!!!

Help!
TIA

Juan
.