PC Review


Reply
Thread Tools Rate Thread

Application.FileSearch

 
 
Cleberton(Brazilian)
Guest
Posts: n/a
 
      26th Oct 2009
I need help to use this application...
The problem is that I installed the new version of Office and my program
were made in Excel 2003.
I used this code:

With Application.FileSearch
.LookIn = "C:\Users\Cleber\Documents\SAUF\Coordenada\SAUCOO\"
.Filename = nome_arquivo
.MatchTextExactly = True
If .Execute > 0 Then
busca = 1
Else
busca = 0
End If
End With

but in Excel 2007 it does not work!
I don't know and I tried a lot of other ways that I found in the help option
but all of them failed..
If somebody could help, please is much important.!
I'm a little new in VBA.
Thanks...
 
Reply With Quote
 
 
 
 
Jacob Skaria
Guest
Posts: n/a
 
      26th Oct 2009
Application.FileSearch is not going to work in 2007..You can try this
alternative function which uses the FileSystemObject...


Function GetFileCount(strPath As String) As Long
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
GetFileCount = -1
GetFileCount = fso.GetFolder(strPath).Files.Count
End Function

If this post helps click Yes
---------------
Jacob Skaria


"Cleberton(Brazilian)" wrote:

> I need help to use this application...
> The problem is that I installed the new version of Office and my program
> were made in Excel 2003.
> I used this code:
>
> With Application.FileSearch
> .LookIn = "C:\Users\Cleber\Documents\SAUF\Coordenada\SAUCOO\"
> .Filename = nome_arquivo
> .MatchTextExactly = True
> If .Execute > 0 Then
> busca = 1
> Else
> busca = 0
> End If
> End With
>
> but in Excel 2007 it does not work!
> I don't know and I tried a lot of other ways that I found in the help option
> but all of them failed..
> If somebody could help, please is much important.!
> I'm a little new in VBA.
> Thanks...

 
Reply With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      26th Oct 2009
to check whether the file exists you can try

If Dir("c:\temp\1.xls",vbNormal) = "" Then
Msgbox "File not found"
Else
'file exists. do something
End If

If this post helps click Yes
---------------
Jacob Skaria


"Jacob Skaria" wrote:

> Application.FileSearch is not going to work in 2007..You can try this
> alternative function which uses the FileSystemObject...
>
>
> Function GetFileCount(strPath As String) As Long
> Dim fso As Object
> Set fso = CreateObject("Scripting.FileSystemObject")
> On Error Resume Next
> GetFileCount = -1
> GetFileCount = fso.GetFolder(strPath).Files.Count
> End Function
>
> If this post helps click Yes
> ---------------
> Jacob Skaria
>
>
> "Cleberton(Brazilian)" wrote:
>
> > I need help to use this application...
> > The problem is that I installed the new version of Office and my program
> > were made in Excel 2003.
> > I used this code:
> >
> > With Application.FileSearch
> > .LookIn = "C:\Users\Cleber\Documents\SAUF\Coordenada\SAUCOO\"
> > .Filename = nome_arquivo
> > .MatchTextExactly = True
> > If .Execute > 0 Then
> > busca = 1
> > Else
> > busca = 0
> > End If
> > End With
> >
> > but in Excel 2007 it does not work!
> > I don't know and I tried a lot of other ways that I found in the help option
> > but all of them failed..
> > If somebody could help, please is much important.!
> > I'm a little new in VBA.
> > Thanks...

 
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 dstiefe Microsoft Excel Programming 3 13th Aug 2009 10:30 PM
Application.Filesearch EA Microsoft Excel Programming 3 17th Aug 2006 10:07 AM
Application.FileSearch Bernie Microsoft Access Form Coding 1 21st Sep 2004 01:14 AM
application.filesearch brian Microsoft Access VBA Modules 2 2nd Aug 2003 06:15 AM


Features
 

Advertising
 

Newsgroups
 


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