View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Nigel Nigel is offline
external usenet poster
 
Posts: 923
Default browse for path in vba

You could use application.getsaveasfilename. The file doesn't have to
exist.

Sub test()
Dim myFolderName As Variant
Dim fpath As String
myFolderName = Application.GetSaveAsFilename _
(InitialFileName:="FileNameWillBeIgnored")

If myFolderName = False Then
Exit Sub 'user hit cancel
Else
fpath = Mid(myFolderName, 1, InStrRev(myFolderName, "\"))
MsgBox fpath
End If
End Sub

Or you could use one of these routines...

Jim Rech has a BrowseForFolder routine at:
http://www.oaltd.co.uk/MVP/Default.htm
(look for BrowseForFolder)

John Walkenbach has one at:
http://j-walk.com/ss/excel/tips/tip29.htm


===
ps. If you and all your users are running xl2002+, take a look at VBA's
help:
application.filedialog(msoFileDialogFolderPicker)

--
Cheers
Nigel



"Helmut" wrote in message
...
I have the following function:

ActiveWorkbook.SaveAs Filename:=Range("filename").Value

Range("filename") contains:
=CONCATENATE(path,"\",Name2," ","2007",".","xls")

Problem:
I want to be able for the person to BROWSE and select the PATH to put into
the CELL = Range("path") so the person doesn't have to type it in.

thanks
Helmut