Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default FILESEARCH OBJECT

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,173
Default 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
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
Lookin property of the FileSearch object [email protected] New Users to Excel 0 December 5th 06 09:37 PM
csv for filetype property of filesearch object smokiibear Excel Programming 3 December 14th 04 04:59 PM
FileSearch Stephen[_6_] Excel Programming 8 June 12th 04 11:14 PM
.FileSearch Randall[_3_] Excel Programming 4 November 26th 03 01:48 AM
Multiple text criteria with FileSearch object? Ed[_9_] Excel Programming 1 September 23rd 03 09:26 PM


All times are GMT +1. The time now is 05:19 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"