View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Lucas Budlong Lucas Budlong is offline
external usenet poster
 
Posts: 9
Default amend this routine to use something other than Application.FileSearch

I'd like to amend this routine to use something other than
Application.FileSearch.

Any thoughts would be most welcome.

Sub RenameJPGs()

Dim oldname As String
Dim newname As String
Dim fname As String
Dim pname As String
Dim i As Integer
Dim d As Variant
fname = "*.jpg" 'filename
pname = "C:\Documents and settings\user\my documents\pics\" 'folder to
use

With Application.FileSearch
.NewSearch
.LookIn = pname
.SearchSubFolders = False
.Filename = fname 'check to see if any files match the fname
If .Execute() 0 Then
For i = 1 To .FoundFiles.Count
d = Format(Date, "dddd")
oldname = .FoundFiles(i)
newname = pname & d & i & ".jpg"
Name oldname As newname
Next
End If
End With


End Sub