Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FileSearch.LookIn Problem...Help!

Status
Not open for further replies.

nesplb

Programmer
Jul 29, 2003
109
NO
Hi!

I have a standard fileserach function that should open files on a given location in word, but somehow the specification of the location fails. It doesn't set det "LookIn" prperty at all. On another server it works just fine, but on this particular server it just won't set. Is there some preferences or something that I should change to fix the problem?

In advance, thanks!:)
Here's the code:

Dim strFileSearch() As Variant
Dim intFileCount As Integer


On Error GoTo feil

Set fs = Application.FileSearch
With fs
.LookIn = "C:\"
'StrDirectory_To_Search_For_files
.FileName = "*.doc" 'type of file to search for
.SearchSubFolders = True
If .Execute > 0 Then

intFileCount = .FoundFiles.Count
ReDim strFileSearch(intFileCount)

For i = 1 To .FoundFiles.Count
Debug.Print .FoundFiles.Count
strFileSearch(i) = .FoundFiles(i)
Next i
Else
f.writelie Date + Time & " Feil ved henting av fil i modul Autoexec/Autoexec"
'MsgBox "There were no files found", vbInformation + vbOKOnly
End If
End With

For i = 1 To intFileCount
Documents.Open strFileSearch(i)
Next i

Pål Nesteby

PDC-Tangen
Norway
 
FileSearch has persistence, that is, it retains property values.

Maybe try adding .NewSearch before your .Lookin
Code:
    With fs
  .NewSearch 
  .LookIn = "C:\"

Gerry
My paintings and sculpture
 
I've tried that as well...

Its very strange...

Pål Nesteby

PDC-Tangen
Norway
 
Nothing I'm afraid....

I'm wathing the variable fs.LookIn in the Locals View and when i come to the line: .LookIn = "C:\" it doesn't change...It only stands: "C:\Documents And Settings\Administrator\My Documents" in the Locals View window.
This never change, unless if I try to set the LookIn variable to "" then it changes, but if I try to change it to for example: "C:\" or "C:\_XSystem\Word\In" it doesn't change at all.

U see?

Should I reinnstall Word? ;-)



Pål Nesteby

PDC-Tangen
Norway
 
That seems drastic.

However, I can not duplicate this. When I change the .Lookin folder, the FileSearch looks in the correct folder.

Anyone else?

Gerry
My paintings and sculpture
 
Yes it's strange.

On another server, running the same version of word, the value changes with the same code...



Pål Nesteby

PDC-Tangen
Norway
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top