I am using this search:
With Application.FileSearch
.LookIn = DefaultFilePath
.TextOrProperty = FleNme
If .Execute(SortBy:=msoSortByFileName, _
SortOrder:=msoSortOrderAscending) > 0 Then
For i = 1 To .FoundFiles.Count
MsgBox .FoundFiles(i)
Next i
Else
MsgBox "There were no files found."
End If
End With

How can I retrieve the file name?
I've tried everything I know, which isn't much.

Re: Getting FileName from Search by Dave

Dave
Tue Jul 22 13:10:08 CDT 2008

Doesn't the msgbox give you the filename?

Rick wrote:
>
> I am using this search:
> With Application.FileSearch
> .LookIn = DefaultFilePath
> .TextOrProperty = FleNme
> If .Execute(SortBy:=msoSortByFileName, _
> SortOrder:=msoSortOrderAscending) > 0 Then
> For i = 1 To .FoundFiles.Count
> MsgBox .FoundFiles(i)
> Next i
> Else
> MsgBox "There were no files found."
> End If
> End With
>
> How can I retrieve the file name?
> I've tried everything I know, which isn't much.

--

Dave Peterson

Re: Getting FileName from Search by Rick

Rick
Tue Jul 22 13:25:05 CDT 2008

Dave;
Yes it does, but how do you save it so one can alter the name?

"Dave Peterson" wrote:

> Doesn't the msgbox give you the filename?
>
> Rick wrote:
> >
> > I am using this search:
> > With Application.FileSearch
> > .LookIn = DefaultFilePath
> > .TextOrProperty = FleNme
> > If .Execute(SortBy:=msoSortByFileName, _
> > SortOrder:=msoSortOrderAscending) > 0 Then
> > For i = 1 To .FoundFiles.Count
> > MsgBox .FoundFiles(i)
> > Next i
> > Else
> > MsgBox "There were no files found."
> > End If
> > End With
> >
> > How can I retrieve the file name?
> > I've tried everything I know, which isn't much.
>
> --
>
> Dave Peterson
>

Re: Getting FileName from Search by Dave

Dave
Tue Jul 22 13:30:19 CDT 2008

Replace the msgbox with this if the file is closed:

name .foundfiles(i) as "C:\somenewname\here.xls"

Look at VBA's help for the Name statement for more info.

Rick wrote:
>
> Dave;
> Yes it does, but how do you save it so one can alter the name?
>
> "Dave Peterson" wrote:
>
> > Doesn't the msgbox give you the filename?
> >
> > Rick wrote:
> > >
> > > I am using this search:
> > > With Application.FileSearch
> > > .LookIn = DefaultFilePath
> > > .TextOrProperty = FleNme
> > > If .Execute(SortBy:=msoSortByFileName, _
> > > SortOrder:=msoSortOrderAscending) > 0 Then
> > > For i = 1 To .FoundFiles.Count
> > > MsgBox .FoundFiles(i)
> > > Next i
> > > Else
> > > MsgBox "There were no files found."
> > > End If
> > > End With
> > >
> > > How can I retrieve the file name?
> > > I've tried everything I know, which isn't much.
> >
> > --
> >
> > Dave Peterson
> >

--

Dave Peterson

Re: Getting FileName from Search by Rick

Rick
Tue Jul 22 13:40:05 CDT 2008

Thanks Dave, I give it a try.

"Dave Peterson" wrote:

> Replace the msgbox with this if the file is closed:
>
> name .foundfiles(i) as "C:\somenewname\here.xls"
>
> Look at VBA's help for the Name statement for more info.
>
> Rick wrote:
> >
> > Dave;
> > Yes it does, but how do you save it so one can alter the name?
> >
> > "Dave Peterson" wrote:
> >
> > > Doesn't the msgbox give you the filename?
> > >
> > > Rick wrote:
> > > >
> > > > I am using this search:
> > > > With Application.FileSearch
> > > > .LookIn = DefaultFilePath
> > > > .TextOrProperty = FleNme
> > > > If .Execute(SortBy:=msoSortByFileName, _
> > > > SortOrder:=msoSortOrderAscending) > 0 Then
> > > > For i = 1 To .FoundFiles.Count
> > > > MsgBox .FoundFiles(i)
> > > > Next i
> > > > Else
> > > > MsgBox "There were no files found."
> > > > End If
> > > > End With
> > > >
> > > > How can I retrieve the file name?
> > > > I've tried everything I know, which isn't much.
> > >
> > > --
> > >
> > > Dave Peterson
> > >
>
> --
>
> Dave Peterson
>