Check for Files to be imported doesn't work in Run-Time

MarionD

Registered User.
Local time
Today, 23:15
Joined
Oct 10, 2000
Messages
431
Hi Everyone,

I hope someone can shed a little light on this for me.
I use the following code to check if there are any text files to be imported when I open my DB. It works fine in a full Version but doesn't work in the Run time Version. By inserting message boxes all over I have found that it probably bombs out on the line " if .execute(sortBy:=.......) It produces no error message . just doesn't import the file - obviously this line returns a 0 Value - but why?

Set fs = Application.FileSearch
With fs
.LookIn = "C:\My Files"
.FileName = "*.exp"
If .Execute(SortBy:=msoSortByLastmodified, SortOrder:=msoSortOrderDescending) >0 then ... (this does not happen in a Run Time Version)
for i=1 to .Foundfiles.count
thefile=.foundFiles(i)
latestdate=FileDateTime(thefile)
if latestDate > lastdate then
......
.......
end if
...
....
End With

I really would appreciate a little help.

Thanks
Marion
Germany
 
Last edited:
Hi Marion,

If .Execute() returns 0 it means it didn't find any files, so it is just going straight to the "End If" and skipping all your code.

Not sure why this wouldn't work in the run time version though if it works in the full version.

You could try changing msoSortByLastmodified to 4 and msoSortOrderDescending to 2 (actual values of the constants), or even removing everything between the brackets so its just,
If .Execute() > 0 then
but I don't think that will make any difference. You could also try adding:
Set fs = Application.FileSearch
With fs
.Newsearch
.LookIn = "C:\My Files"
.FileName = "*.exp"

.FileType = msoFileTypeAllFiles ' Or .FileType = 1

Other then that, just check to make sure the folder "C:\My Files" exists, and there is a file in it with an ".exp" extension.
For some reason, filesearch seems to default to "C:\My Documents" if it can't find the folder you specify, so it might be worth adding a file to "My Documents" to see if it that comes up with any results.

Dave
 
vb versus VB scripting

Hello Dave,

Thanks for the reply. I´ve tried the suggestions but unfortunately still did not get the results required. Someone has suggested that the file search object is VB scripting and that this does not work in the runtime version. Can anybody clarify this for me?
Thanks in advance,
Marion
 
I had a similar problem with the FileSearch method. My Access 97 FileSearch function worked fine in Runtime for Windows 9x but stopped working when we moved to Windows XP. I had a fit trying to figure it out until I used a different parameter when searching for my files. I was lucky that all of my files had the same text string "within" the files. As an example, my code below shows the before and after parameters I was using...

With Application.FileSearch
.NewSearch
.LookIn = "\\server\partition\Databases"
.SearchSubFolders = False
'.FileName = "ABC123.*" 'Old way
.TextOrProperty = "ABC123" 'New way
'.MatchTextExactly = False 'Old way
.MatchTextExactly = True 'New way
.FileType = msoFileTypeAllFiles 'A reference must be made to the db when selecting this option (for the first time). Type ".FileType = " (without the quotes) and after you type the =, you will be prompted by Access if you want to add the needed reference.
If .Execute() > 0 Then

HTH
 
Hi Ghudson,

Thanks for the advice. I still can't get the da.... thing to work on the runtime Version. I've decided to take a "whole new approach" and have solved the problem another way. It always irritates me though when I can't figure out why it isn't working!

Thanks for the help anyway - I'll continue trying -I'm sure there is really no reason why it should not work in a runtime Version


Marion
 

Users who are viewing this thread

Back
Top Bottom