Drop this into a module and run 'DoSomething' as an example
Function PickFolder(strStartDir As Variant) As String
Dim SA As Object, F As Object
Set SA = CreateObject("Shell.application")
Set F = SA.BrowseForFolder(0, "Choose a folder", 0, strStartDir)
If (Not F Is Nothing) Then
PickFolder = F.items.Item.Path
End If
Set F = Nothing
Set SA = Nothing
End Function
Sub DoSomething()
userfile = PickFolder(strStartDir)
If userfile = "" Then
MsgBox "Canceled"
End If
With Application.FileSearch
.SearchSubFolders = True
.NewSearch
.Filename = ".xls"
.LookIn = userfile
.FileType = msoFileTypeExcelWorkbooks
.Execute
ffc = .FoundFiles.Count
MsgBox ffc
End With
End Sub
--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03
----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :-)
----------------------------------------------------------------------------
"Ramius" wrote in message
...
I recorded an Import External Data macro that I wish to use on other
files.
It works beautifully, but only on that one specfic file in that one
directory. I can get the Visual Basic code for that macro to where I can
edit it, but don't know what to substitute for the directory/file so that
the
macro is forced to ask.
|