Group:  Microsoft Access ยป microsoft.public.access.modulesdaovba
Thread: Copy of File in filesearch result

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Copy of File in filesearch result
joseph micheli 19.09.2006 15:59:02
I'm using the filesearch in Access VBA to determine if a specified Excel file
exists within a specified subdirectory using the following:

With Application.FileSearch
.NewSearch
.LookIn = strSrceFolder
.FileName = strFile

When a copy of the Excel file has been created through Excel (opening the
file as read only and saving), the filesearch finds a match. The filename is
specified without any wildcard characters. Any work around suggestions would
be greatly appreciated.

Thanks.
--
Joe Micheli CPA, CMA, CFM, CPIM
RE: Copy of File in filesearch result
Klatuu 19.09.2006 17:07:02
I don't understand your question at all. What are you trying to accomplish?
If the file is in the folder and you can find the match, what is wrong?

"joseph micheli" wrote:

[Quoted Text]
> I'm using the filesearch in Access VBA to determine if a specified Excel file
> exists within a specified subdirectory using the following:
>
> With Application.FileSearch
> .NewSearch
> .LookIn = strSrceFolder
> .FileName = strFile
>
> When a copy of the Excel file has been created through Excel (opening the
> file as read only and saving), the filesearch finds a match. The filename is
> specified without any wildcard characters. Any work around suggestions would
> be greatly appreciated.
>
> Thanks.
> --
> Joe Micheli CPA, CMA, CFM, CPIM
RE: Copy of File in filesearch result
joseph micheli 19.09.2006 18:30:02
If the file is found, I want to perform a rename on the file to move it to
another subdirectory. The copy of the file makes my If Execute () true, but
when the rename command tries to rename the file using the name stored in
strFile, it fails because it cannot find the file. I do not want the copy of
the file to be mistaken for the actual file name.
--
Joe Micheli CPA, CMA, CFM, CPIM


"Klatuu" wrote:

[Quoted Text]
> I don't understand your question at all. What are you trying to accomplish?
> If the file is in the folder and you can find the match, what is wrong?
>
> "joseph micheli" wrote:
>
> > I'm using the filesearch in Access VBA to determine if a specified Excel file
> > exists within a specified subdirectory using the following:
> >
> > With Application.FileSearch
> > .NewSearch
> > .LookIn = strSrceFolder
> > .FileName = strFile
> >
> > When a copy of the Excel file has been created through Excel (opening the
> > file as read only and saving), the filesearch finds a match. The filename is
> > specified without any wildcard characters. Any work around suggestions would
> > be greatly appreciated.
> >
> > Thanks.
> > --
> > Joe Micheli CPA, CMA, CFM, CPIM
RE: Copy of File in filesearch result
Klatuu 19.09.2006 18:56:01
If you just want to rename it, use the Name statement.
If you want to make a copy, use the FileCopy statement.
If you want to delete the original after copying, use the Kill statement.

Using the Filecopy followed by the Kill would be the same as using the Name
statement.

You can get details on these statements in VBA Help

"joseph micheli" wrote:

[Quoted Text]
> If the file is found, I want to perform a rename on the file to move it to
> another subdirectory. The copy of the file makes my If Execute () true, but
> when the rename command tries to rename the file using the name stored in
> strFile, it fails because it cannot find the file. I do not want the copy of
> the file to be mistaken for the actual file name.
> --
> Joe Micheli CPA, CMA, CFM, CPIM
>
>
> "Klatuu" wrote:
>
> > I don't understand your question at all. What are you trying to accomplish?
> > If the file is in the folder and you can find the match, what is wrong?
> >
> > "joseph micheli" wrote:
> >
> > > I'm using the filesearch in Access VBA to determine if a specified Excel file
> > > exists within a specified subdirectory using the following:
> > >
> > > With Application.FileSearch
> > > .NewSearch
> > > .LookIn = strSrceFolder
> > > .FileName = strFile
> > >
> > > When a copy of the Excel file has been created through Excel (opening the
> > > file as read only and saving), the filesearch finds a match. The filename is
> > > specified without any wildcard characters. Any work around suggestions would
> > > be greatly appreciated.
> > >
> > > Thanks.
> > > --
> > > Joe Micheli CPA, CMA, CFM, CPIM
RE: Copy of File in filesearch result
joseph micheli 20.09.2006 13:41:02
I don't have any trouble with the name statement. The problem is when the
file search finds the filename with the words "Copy of" in front of it. It
is causing the Execute statement to evaluate to true when it is, in fact
false.
--
Joe Micheli CPA, CMA, CFM, CPIM


"Klatuu" wrote:

[Quoted Text]
> If you just want to rename it, use the Name statement.
> If you want to make a copy, use the FileCopy statement.
> If you want to delete the original after copying, use the Kill statement.
>
> Using the Filecopy followed by the Kill would be the same as using the Name
> statement.
>
> You can get details on these statements in VBA Help
>
> "joseph micheli" wrote:
>
> > If the file is found, I want to perform a rename on the file to move it to
> > another subdirectory. The copy of the file makes my If Execute () true, but
> > when the rename command tries to rename the file using the name stored in
> > strFile, it fails because it cannot find the file. I do not want the copy of
> > the file to be mistaken for the actual file name.
> > --
> > Joe Micheli CPA, CMA, CFM, CPIM
> >
> >
> > "Klatuu" wrote:
> >
> > > I don't understand your question at all. What are you trying to accomplish?
> > > If the file is in the folder and you can find the match, what is wrong?
> > >
> > > "joseph micheli" wrote:
> > >
> > > > I'm using the filesearch in Access VBA to determine if a specified Excel file
> > > > exists within a specified subdirectory using the following:
> > > >
> > > > With Application.FileSearch
> > > > .NewSearch
> > > > .LookIn = strSrceFolder
> > > > .FileName = strFile
> > > >
> > > > When a copy of the Excel file has been created through Excel (opening the
> > > > file as read only and saving), the filesearch finds a match. The filename is
> > > > specified without any wildcard characters. Any work around suggestions would
> > > > be greatly appreciated.
> > > >
> > > > Thanks.
> > > > --
> > > > Joe Micheli CPA, CMA, CFM, CPIM
Re: Copy of File in filesearch result
"Dirk Goldgar" <dg[ at ]NOdataSPAMgnostics.com> 20.09.2006 14:15:51
"joseph micheli" <josephmicheli[ at ]discussions.microsoft.com> wrote in
message news:0A8B2A5F-35C6-4980-B4B4-F6F5770BF139[ at ]microsoft.com
[Quoted Text]
> I'm using the filesearch in Access VBA to determine if a specified
> Excel file exists within a specified subdirectory using the following:
>
> With Application.FileSearch
> .NewSearch
> .LookIn = strSrceFolder
> .FileName = strFile
>
> When a copy of the Excel file has been created through Excel (opening
> the file as read only and saving), the filesearch finds a match. The
> filename is specified without any wildcard characters. Any work
> around suggestions would be greatly appreciated.

FileSearch is looking for an inexact match. I don't know if there's a
way to get it to return only an exact match. I recommend that you use
the Dir() function instead:

Dim strFilePath As String

strFilePath = strSrceFolder
If Right(strSrceFolder, 1) <> "\" Then
strFilePath = strFilePath & "\"
End If
strFilePath = strFilePath & strFile

If Len(Dir(strFilePath)) > 0 Then
' The file exists.
Else
' It doesn't.
End If

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


RE: Copy of File in filesearch result
Klatuu 20.09.2006 14:41:01
Dirk is correct. You had not mentioned the Copy Of before. In any case, the
Dir function is probably more widely used than the FileSearch.

"joseph micheli" wrote:

[Quoted Text]
> I don't have any trouble with the name statement. The problem is when the
> file search finds the filename with the words "Copy of" in front of it. It
> is causing the Execute statement to evaluate to true when it is, in fact
> false.
> --
> Joe Micheli CPA, CMA, CFM, CPIM
>
>
> "Klatuu" wrote:
>
> > If you just want to rename it, use the Name statement.
> > If you want to make a copy, use the FileCopy statement.
> > If you want to delete the original after copying, use the Kill statement.
> >
> > Using the Filecopy followed by the Kill would be the same as using the Name
> > statement.
> >
> > You can get details on these statements in VBA Help
> >
> > "joseph micheli" wrote:
> >
> > > If the file is found, I want to perform a rename on the file to move it to
> > > another subdirectory. The copy of the file makes my If Execute () true, but
> > > when the rename command tries to rename the file using the name stored in
> > > strFile, it fails because it cannot find the file. I do not want the copy of
> > > the file to be mistaken for the actual file name.
> > > --
> > > Joe Micheli CPA, CMA, CFM, CPIM
> > >
> > >
> > > "Klatuu" wrote:
> > >
> > > > I don't understand your question at all. What are you trying to accomplish?
> > > > If the file is in the folder and you can find the match, what is wrong?
> > > >
> > > > "joseph micheli" wrote:
> > > >
> > > > > I'm using the filesearch in Access VBA to determine if a specified Excel file
> > > > > exists within a specified subdirectory using the following:
> > > > >
> > > > > With Application.FileSearch
> > > > > .NewSearch
> > > > > .LookIn = strSrceFolder
> > > > > .FileName = strFile
> > > > >
> > > > > When a copy of the Excel file has been created through Excel (opening the
> > > > > file as read only and saving), the filesearch finds a match. The filename is
> > > > > specified without any wildcard characters. Any work around suggestions would
> > > > > be greatly appreciated.
> > > > >
> > > > > Thanks.
> > > > > --
> > > > > Joe Micheli CPA, CMA, CFM, CPIM

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net