P
Peter
Please can someone help me?
I have a snipit of code below:
In a nutshell: the filefind (If .Execute) says it has found a file when the
file has been renamed to something else!
The line near the bottom:
Name AccNumber & ".pdf" As AccNumber & DateFile & ".pdf"
.. . . . renames the files with the extra bit Datefile where DateFile =
"0304" the date of the file (Mar 2004)
Assume AccNumber = 12345678
So that a file named 12345678.pdf will be renamed 123456780304.pdf
When I rerun the routine it will look for 12345678.pdf and, if not found
(myFoundfiles = 0), should skip the next section.
However myFoundfiles gets a value of 1 even if it searches for 12345678.pdf
(which no longer exists) when there actually is the file 123456780304.pdf.
They are close in name - first 8 charaters are identical
But I also tried adding an "AC" at the beginning of the changed name and it
made no difference still "found" the file and then bombs trying to rename a
non-existant file. Any help or advive would me most appreciated.
Thanks,
Peter Bircher
myFoundfiles = 0
With Application.FileSearch
.NewSearch
.LookIn = AccountsDirectory
.SearchSubFolders = False
.Filename = AccNumber & ".pdf"
.MatchTextExactly = True
.FileType = msoFileTypeAllFiles
If .Execute(SortBy:=msoSortByFileName, _
SortOrder:=msoSortOrderAscending) > 0 Then
myFoundfiles = .FoundFiles.Count
End If
End With
If myFoundfiles > 0 Then 'skip this if file not found
Name AccNumber & ".pdf" As AccNumber & DateFile & ".pdf"
etc
etc
End if
I have a snipit of code below:
In a nutshell: the filefind (If .Execute) says it has found a file when the
file has been renamed to something else!
The line near the bottom:
Name AccNumber & ".pdf" As AccNumber & DateFile & ".pdf"
.. . . . renames the files with the extra bit Datefile where DateFile =
"0304" the date of the file (Mar 2004)
Assume AccNumber = 12345678
So that a file named 12345678.pdf will be renamed 123456780304.pdf
When I rerun the routine it will look for 12345678.pdf and, if not found
(myFoundfiles = 0), should skip the next section.
However myFoundfiles gets a value of 1 even if it searches for 12345678.pdf
(which no longer exists) when there actually is the file 123456780304.pdf.
They are close in name - first 8 charaters are identical
But I also tried adding an "AC" at the beginning of the changed name and it
made no difference still "found" the file and then bombs trying to rename a
non-existant file. Any help or advive would me most appreciated.
Thanks,
Peter Bircher
myFoundfiles = 0
With Application.FileSearch
.NewSearch
.LookIn = AccountsDirectory
.SearchSubFolders = False
.Filename = AccNumber & ".pdf"
.MatchTextExactly = True
.FileType = msoFileTypeAllFiles
If .Execute(SortBy:=msoSortByFileName, _
SortOrder:=msoSortOrderAscending) > 0 Then
myFoundfiles = .FoundFiles.Count
End If
End With
If myFoundfiles > 0 Then 'skip this if file not found
Name AccNumber & ".pdf" As AccNumber & DateFile & ".pdf"
etc
etc
End if