LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Invalid Pathname

I have created an application which searches for network folder contents and
poulates a list on an excel spreadsheet with hyperlinks to he network files.
In order to determine the file locations the user must enter a valid pathname
into an inputbox.

The application works fine as long as the path is either valid or the user
selects 'cancel' from the inputbox to exit the macro. However, if a typo is
made and a completely invalid path entered then the macro just hangs excel
(excel 2000) or starts reading files from C:\Documents and Settings\......

Can anyone suggest how best to check if path is valid? If it is known to be
invalid then I can easily exit the macro with a message displayed to the user.

The part code surrently used is:

sf1 = InputBox("Enter the correct path for specifications", "Specification
Folder Location")
If sf1 = "" Then Exit Sub

'Reset search parameters
sf2 = MsgBox("Do you want to include sub-folders in the search?", vbYesNo +
vbExclamation)
With Application.FileSearch
.NewSearch
.LookIn = sf1
If sf2 = vbYes Then
.SearchSubFolders = True
Else: .SearchSubFolders = False
End If
.FileType = msoFileTypeAllFiles
.Execute
'To prevent misuse and macro errors
If .FoundFiles.Count 1000 Then
MsgBox "You are about to add over 1000 file references." & vbCrLf _
& vbCrLf & "This will create errors within the macros in this
workbook" & vbCrLf _
& vbCrLf & "The procedure will now cancel"
GoTo Line3
ElseIf .FoundFiles.Count = 0 Then
MsgBox "No files found." & vbCrLf & vbCrLf & _
"Check that specifications are located in the correct folder and
correct filepath has been used"
GoTo Line3
End If
End With
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
vlookup dynamic pathname mdhodgson Excel Discussion (Misc queries) 3 September 5th 08 03:27 AM
Using a dynamic pathname in VLOOKUP Mike D[_2_] Excel Worksheet Functions 7 July 16th 07 09:35 PM
Filecopy and UNC-pathname Jos Vens Excel Programming 7 February 12th 04 11:10 AM
Extract Workbook name from pathname ? Don Wiss Excel Programming 4 September 30th 03 01:48 PM
LoadPicture Pathname or no Pathname Philipp Schramek Excel Programming 1 July 8th 03 03:30 PM


All times are GMT +1. The time now is 02:43 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"