MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

search in UNC path

  Asked By: Aysel    Date: Sep 24    Category: MS Office    Views: 1619

I am trying to search in a UNC path and the search will not return a
true if the file is found. What is happening is that the file is there,
but not being found. The code then tries to create a new workbook and
name the file - it tells me the file exists do I want to over write it.
It don't want to overwrite - I want to append. It works if I have the
file on my PC and give the full path, but when I put it on the network
it blows up.

Please help!!!!!

This is my code:

myDir = CurDir

'myPath = "\\gcoda58\Supplies\Supplies\"

Set fsoFileSearch = Nothing

'Set fsoFileSearch =

Set fsoFileSearch = Application.FileSearch.SearchScopes

today = Now()

MyDate = DatePart("ww", today)

wbName = "Employee Upload_" & MyDate

With fsoFileSearch


'.LookIn = myPath

.LookIn = myDir

.Filename = wbName

.SearchSubFolders = False

.MatchTextExactly = True

.FileType = msoFileTypeExcelWorkbooks

If .Execute() > 0 Then



1 Answer Found

Answer #1    Answered By: Gavril Bonkob     Answered On: Sep 24

If you do the search  manually using the network path  does it work?

Also you may need three or four backslashes at the beginning.

You are using CurDir?

To find out what is happening, put  a breakpoint on the .execute and then, when
it breaks, put the mouse over the search variables and see if they are
exactly what you expect.

Not directly relevant but have you seen this bit in the help files?
Use the NewSearch method to reset the search criteria to the default settings.
All property values are retained after each search is run, and by using the
NewSearch method you can selectively set properties for the next file  search
without manually resetting previous property values. The following example
resets the search criteria to the default settings before beginning a new

With Application.FileSearch
.LookIn = "C:\My Documents"
.SearchSubFolders = True
.FileName = "Run"
.MatchTextExactly = True
.FileType = msoFileTypeAllFiles
End With

Didn't find what you were looking for? Find more on search in UNC path Or get search suggestion and latest updates.