Selecting a Folder or Subfolder

G

Guest

Hi everyone from a new comer

My application extracts filenames from folders or subfolders. Sometimes, the
folders are deep down making it cumbersome as well as error-prone, for my
colleagues (users of this application), to type the long path in a textbox.

I need to include a code which helps the users select a folder or a
subfolder from a dialogbox; like the FileOpen dialogbox. The FileOpen has a
restriction of choosing particular file(s). Although, I can truncate the
returned string from this dialogobx to extract the path - but I don't want
this method to use for some reasons.

I expect the members of the forum suggest me more professional way to solve
this problem.

Regards,

Rabi
 
G

Guest

I am afraid, I did not describe my query clearly. I tried to describe it more
clearly, below:

I want to read a folder name on the disk (in order to extract all the files
under this folder and its subfolders). Presently, my application requires to
type the path, in a textbox, as below, for example:

"d:\documents\projects\reports\cities\"

I want a way to choose a folder, like the above , for example, by clicking
from the list of folders instead of typing the path (sometimes much longer
than the above example). Consequently, my applications extracts all the files
under this folder and its subfolders.

Please note that I need to read the FolderName only, not the FileName(s).

Regards,

Rabi
 
G

Guest

Thanks NickHK for the response. I am afraid it is not "VBA for Excel"
complaint code.
On pasting the code, API declaration statements are not identified by the VBE.

Is there something more to have this code run.

Regards,

Rabi
 
N

NickHK

As the comment says :
"hwnd of the window that receives messages from the call. Can be your
application or the handle from GetDesktopWindow()"
So use
.hOwner = GetDesktopWindow()
and add the declaration with the other Declare statements
Private Declare Function GetDesktopWindow Lib "user32" Alias
"GetDesktopWindow" () As Long

The only other difference maybe that you need a destination for the output
instead a "Label1".

NickHK
 

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