BrowseForFolder

P

pfsardella

Hello :

I'm playing with Jim Rech's BrowseForFolder workbook on my Win98SE
machine with Excel97.

I encountered no difficulties using this in the original workbook
(except for the fact that Excel flags the BrowseCallBackFuncAddress
function if I try to compile the workbook, which he has detailed in
the comments). It opens to the desired directory.

Rather than having this set of routines spread out in separate
workbooks, .... I tried calling the GetDirectory function in the
original workbook from a routine in another workbook. In this case, it
displays the "Browse for Folder" form, but it defaults to the root
directory. I'm limited as to understanding some of the code's
functioning, so I'm guessing that the code has to be in the calling
project (GetCurrentVbaProject). Is my assumption true?

Thanks for any help.

BrowseForFolder
http://www.bmsltd.ie/MVP/Default.htm

Sincerely,
Paul Sardella
 
P

pfsardella

I want to pre-select the initial folder. I don't want to start in the
root directory and then navigate through a half dozen directories.
 
N

Norman Jones

Hi PF,

Try:

'=============>>
Sub Tester02()
Dim MyPath As String
Dim SaveDriveDir As String
Dim RetStr As String, Flags As Long, DoCenter As Boolean
Flags = BIF_RETURNONLYFSDIRS
Flags = Flags + BIF_NEWDIALOGSTYLE

SaveDriveDir = CurDir
MyPath = "C:\Documents and Settings" '<<==== CHANGE
ChDrive MyPath
ChDir MyPath

RetStr = GetDirectory(CurDir, Flags, DoCenter, _
"Please select a location to store data files")
If RetStr <> "" Then MsgBox RetStr

ChDrive SaveDriveDir
ChDir SaveDriveDir

End Sub
'<<=============
 
P

pfsardella

Norman,

Many thanks. Works well.

My mistake : I was using MyPath as the first argument to GetDirectory.
Using CurDir for the first argument resolved the issue.

Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top