PC Review


Reply
Thread Tools Rate Thread

Application.Filesearch FileCopy

 
 
OP
Guest
Posts: n/a
 
      28th Aug 2011
Hi there,

I guess the subject has already been raised a thousand times, but I am
at lost wirth my macro. Of course everything worked well with Excel
2003; but as Filesearch has been removed from 2010 I can't really find a
clue to solve my problem. I looked over a couple of forums for a
filescript substitute but found nothing simple enough for me to
understand.

Here is my problem :

I have variables, (Fpath and Fname) that I run through the Filesearch
funtion. That returns me a single filename (Fil) that I use to copy to a
another folder... See the code below.

Would appreciate if anybody could help me to master this under 2010.

Thanks


With Application.FileSearch
..NewSearch
..LookIn = FPath
..SearchSubFolders = True
..Filename = fName
If .Execute(SortBy:=msoSortByFileName, _
SortOrder:=msoSortOrderAscending) > 0 Then
Fil = .FoundFiles(1)
Else
MsgBox "There were no files found."
Exit Sub
End If
End With
FileCopy Fil, dest + fName
 
Reply With Quote
 
 
 
 
Don Guillett
Guest
Posts: n/a
 
      28th Aug 2011
On Aug 28, 1:39*pm, OP <m...@privacy.net> wrote:
> Hi there,
>
> I guess the subject has already been raised a thousand times, but I am
> at lost wirth my macro. Of course everything worked well with Excel
> 2003; but as Filesearch has been removed from 2010 I can't really find a
> clue to solve my problem. I looked over a couple of forums for a
> filescript substitute but found nothing simple enough for me to
> understand.
>
> Here is my problem :
>
> I have variables, (Fpath and Fname) that I run through the Filesearch
> funtion. That returns me a single filename (Fil) that I use to copy to a
> another folder... See the code below.
>
> Would appreciate if anybody could help me to master this under 2010.
>
> Thanks
>
> With Application.FileSearch
> .NewSearch
> .LookIn = FPath
> .SearchSubFolders = True
> .Filename = fName
> If .Execute(SortBy:=msoSortByFileName, _
> SortOrder:=msoSortOrderAscending) > 0 Then
> Fil = .FoundFiles(1)
> * * * * Else
> * * * * MsgBox "There were no files found."
> * * * * Exit Sub
> End If
> End With
> FileCopy Fil, dest + fName


Have a look in the vba help index for DIR. Post back if you still
have problems
 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      29th Aug 2011
Ron de Bruin provides a couple of alternatives to .filesearch here:
http://www.rondebruin.nl/fso.htm
and
http://www.rondebruin.nl/copy3.htm

On 08/28/2011 13:39, OP wrote:
> Hi there,
>
> I guess the subject has already been raised a thousand times, but I am
> at lost wirth my macro. Of course everything worked well with Excel
> 2003; but as Filesearch has been removed from 2010 I can't really find a
> clue to solve my problem. I looked over a couple of forums for a
> filescript substitute but found nothing simple enough for me to
> understand.
>
> Here is my problem :
>
> I have variables, (Fpath and Fname) that I run through the Filesearch
> funtion. That returns me a single filename (Fil) that I use to copy to a
> another folder... See the code below.
>
> Would appreciate if anybody could help me to master this under 2010.
>
> Thanks
>
>
> With Application.FileSearch
> .NewSearch
> .LookIn = FPath
> .SearchSubFolders = True
> .Filename = fName
> If .Execute(SortBy:=msoSortByFileName, _
> SortOrder:=msoSortOrderAscending)> 0 Then
> Fil = .FoundFiles(1)
> Else
> MsgBox "There were no files found."
> Exit Sub
> End If
> End With
> FileCopy Fil, dest + fName


--
Dave Peterson
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA - Application.Filesearch Nelson79 Microsoft Excel Discussion 0 12th Jun 2011 10:58 AM
Application.FileSearch patrick_nyr Microsoft Excel Programming 3 24th Aug 2009 04:28 PM
application.filesearch dstiefe Microsoft Excel Programming 3 13th Aug 2009 10:30 PM
Set fs = Application.FileSearch ucanalways@gmail.com Microsoft Excel Programming 4 15th Apr 2008 10:17 PM
What is better: Application.FileSearch or Dir ?? WhytheQ Microsoft Excel Programming 9 25th Oct 2006 01:29 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:32 PM.