Thread
:
FILESEARCH OBJECT
View Single Post
#
1
Posted to microsoft.public.excel.programming
Nick Hodge
external usenet poster
Posts: 1,173
FILESEARCH OBJECT
Jason
This shouldn't be an issue but try using the Execute method explicitly and
then set the AlwaysAccurate parameter to True. This will ensure the index
of the folder is updated before the filesearch, like (untested). You might
also try NewSearch each time to invoke 'new' parameters.
With fs
.LookIn = "I:\Finance\PIMS\Archived Log"
.Filename = "Log " & Format(Now, "dd mmm yyyy") & ".xls"
If .Execute(, , True) = 0 Then
ThisWorkbook.SaveCopyAs "I:\Finance\PIMS\Archived
_ Log\Log " & Format(Now, "dd mmm _ yyyy") & ".xls"
End If
End With
PS: Upper case posts are considered shouting and rude in text only NGs
--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
HIS
"jason" wrote in message
om...
HOW COME IF I RUN THE BELOW AND IF THE .FoundFiles.Count DOES ACTUALLY
EQUAL 0 THEN IT WILL SAVECOPYAS OF THE FILE IN THE APPROPRIATE PLACE.
THE TROUBLE IS THAT IF I RUN THE CODE AGAIN IT STILL HAS THE
.FoundFiles.Count AS 0 !! THE ONLY WAY IT WILL RECOGNISE THE NEWLY
SAVED FILE IS IF I LOG OFF THE SERVER AND RE-RUN THE CODE !
ANY ONE GOT ANY IDEAS HOW I CAN MODIFY THE CODE TO AVOID THE ABOVE?
ANY HELK GREATLY APPRECIATED.
JASON
Function SaveThisWorkBook()
Dim fs As FileSearch
Set fs = Application.FileSearch
With fs
.LookIn = "I:\Finance\PIMS\Archived Log"
.Filename = "Log " & Format(Now, "dd mmm yyyy") & ".xls"
If .FoundFiles.Count = 0 Then
ThisWorkbook.SaveCopyAs "I:\Finance\PIMS\Archived
_ Log\Log " & Format(Now, "dd mmm _ yyyy") & ".xls"
End If
End With
Set fs = Nothing
End Function
Reply With Quote
Nick Hodge
View Public Profile
Find all posts by Nick Hodge