Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default prompt user to specify a directory

Hi,
How do I prompt user to specify a directory? I don't want them to type in
the directory but instead they can browse around and select the correct path
just like in "Open File".
Thanks a lot,
Mini
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default prompt user to specify a directory

Try the API call:

Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long

BrowseInfo is a structure as follows:

Private Type BrowseInfo
hWndOwner As Long
pIDLRoot As Long
pszDisplayName As Long
lpszTitle As Long
ulFlags As Long
lpfnCallback As Long
lParam As Long
iImage As Long
End Type



"mini" wrote:

Hi,
How do I prompt user to specify a directory? I don't want them to type in
the directory but instead they can browse around and select the correct path
just like in "Open File".
Thanks a lot,
Mini

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default prompt user to specify a directory

Thanks for the reply. Could you please elaborate more on how to do it.
What's API?
Mini

"AA2e72E" wrote:

Try the API call:

Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long

BrowseInfo is a structure as follows:

Private Type BrowseInfo
hWndOwner As Long
pIDLRoot As Long
pszDisplayName As Long
lpszTitle As Long
ulFlags As Long
lpfnCallback As Long
lParam As Long
iImage As Long
End Type



"mini" wrote:

Hi,
How do I prompt user to specify a directory? I don't want them to type in
the directory but instead they can browse around and select the correct path
just like in "Open File".
Thanks a lot,
Mini

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default prompt user to specify a directory

API is Application Programming Interface.

For SHBropwseForFolder, go to http://www.allapi.net/apilist/s.shtml and look
up the API.

An alternative way is:

Function aa()
Set sa = CreateObject("Shell.Application")
Set xx = sa.browseforfolder(0, "Select Folder", 0, 0)
aa = xx.Items.Item.Path
Set xx = Nothing
Set sa = Nothing
End Function


"mini" wrote:

Thanks for the reply. Could you please elaborate more on how to do it.
What's API?
Mini

"AA2e72E" wrote:

Try the API call:

Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long

BrowseInfo is a structure as follows:

Private Type BrowseInfo
hWndOwner As Long
pIDLRoot As Long
pszDisplayName As Long
lpszTitle As Long
ulFlags As Long
lpfnCallback As Long
lParam As Long
iImage As Long
End Type



"mini" wrote:

Hi,
How do I prompt user to specify a directory? I don't want them to type in
the directory but instead they can browse around and select the correct path
just like in "Open File".
Thanks a lot,
Mini

  #5   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default prompt user to specify a directory

Either one of these may be of some use to you.

Sub test()
Dim FName As String
Dim WkBk As Workbook

FName = Application.GetOpenFilename
If FName < "False" Then _
Set WkBk = Workbooks.Open(Filename:=FName)
End Sub

Sub Test2()
Dim WkBk As Workbook

Application.Dialogs(xlDialogOpen).Show
If ActiveWorkbook.Name < ThisWorkbook.Name Then _
Set WkBk = ActiveWorkbook
End Sub



"mini" wrote:

Hi,
How do I prompt user to specify a directory? I don't want them to type in
the directory but instead they can browse around and select the correct path
just like in "Open File".
Thanks a lot,
Mini



  #6   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default prompt user to specify a directory

I'm sorry, you said browse for folder, not browse for file. I use the API
call that has already been posted.



"JMB" wrote:

Either one of these may be of some use to you.

Sub test()
Dim FName As String
Dim WkBk As Workbook

FName = Application.GetOpenFilename
If FName < "False" Then _
Set WkBk = Workbooks.Open(Filename:=FName)
End Sub

Sub Test2()
Dim WkBk As Workbook

Application.Dialogs(xlDialogOpen).Show
If ActiveWorkbook.Name < ThisWorkbook.Name Then _
Set WkBk = ActiveWorkbook
End Sub



"mini" wrote:

Hi,
How do I prompt user to specify a directory? I don't want them to type in
the directory but instead they can browse around and select the correct path
just like in "Open File".
Thanks a lot,
Mini

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
If prompt for user data Miree Excel Discussion (Misc queries) 0 August 19th 08 12:06 PM
save prompt for user exit, but no save prompt for batch import? lpj Excel Discussion (Misc queries) 1 February 25th 06 02:08 AM
Prompt user for a filename J S Excel Programming 3 April 8th 05 11:15 PM
Help with user prompt Rob Gould Excel Discussion (Misc queries) 5 March 14th 05 12:38 PM
Command Prompt to a Directory sailingdan[_2_] Excel Programming 0 June 23rd 04 05:08 PM


All times are GMT +1. The time now is 06:03 AM.

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

About Us

"It's about Microsoft Excel"