Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Selecting a Folder or Subfolder

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Selecting a Folder or Subfolder - more clearly described

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Selecting a Folder or Subfolder

Use the Windows API SHBrowseForFolder etc :

http://vbnet.mvps.org/code/browse/browsefolders.htm

NickHK

"Rabi" wrote in message
...
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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Selecting a Folder or Subfolder

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

"NickHK" wrote:

Use the Windows API SHBrowseForFolder etc :

http://vbnet.mvps.org/code/browse/browsefolders.htm

NickHK

"Rabi" wrote in message
...
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




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Selecting a Folder or Subfolder

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

"Rabi" wrote in message
...
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

"NickHK" wrote:

Use the Windows API SHBrowseForFolder etc :

http://vbnet.mvps.org/code/browse/browsefolders.htm

NickHK

"Rabi" wrote in message
...
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








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Selecting a Folder or Subfolder

Now, I got the point. Thank you very much NickHK.

Best regards,

Rabi

"NickHK" wrote:

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

"Rabi" wrote in message
...
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

"NickHK" wrote:

Use the Windows API SHBrowseForFolder etc :

http://vbnet.mvps.org/code/browse/browsefolders.htm

NickHK

"Rabi" wrote in message
...
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






Reply
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
Saving a workbook by creating a folder & subfolder Gaura215 Excel Worksheet Functions 0 February 1st 11 10:47 AM
Selecting the most recent file in a folder by Macro/VBA script [email protected] Excel Programming 3 July 20th 06 06:06 PM
Selecting an output folder simonc Excel Programming 9 February 20th 06 08:30 PM
subfolder Loop? But, only one.... foamfollower Excel Programming 1 November 12th 03 01:37 AM
how to step thru only one subfolder of a folder to find like files foamfollower Excel Programming 1 November 11th 03 08:40 PM


All times are GMT +1. The time now is 01:13 PM.

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

About Us

"It's about Microsoft Excel"