Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Need a "GetFolder method"

I have used the "GetSaveAsFilename method" to let the user give a file name.
But now I need a "GetFolder method" that will let the user give a folder
name. The "GetFolder method" does not exist in VBA. Has anyone programmed
something that can do the trick ? - or can you give me a hint on how to do
it ?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Need a "GetFolder method"

Helge,

Download Jim Rech's BrowseForFolder example at
http://www.bmsltd.co.uk/DLCount/DLCo...eForFolder.zip .


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Helge V. Larsen" wrote in message
...
I have used the "GetSaveAsFilename method" to let the user give

a file name.
But now I need a "GetFolder method" that will let the user give

a folder
name. The "GetFolder method" does not exist in VBA. Has anyone

programmed
something that can do the trick ? - or can you give me a hint

on how to do
it ?




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Need a "GetFolder method"

The easiest way to do this might be by calling on a Windows API function:

Sub ShowBrowseForFolder()
Dim Fld As Folder
Dim sh As New Shell
Set Fld = sh.BrowseForFolder(0, "Select a Folder", 1, "c:\")
If Not Fld Is Nothing Then
MsgBox Fld.Self.Path
End If
End Sub

For this to work you have to set a Tools, Reference to SHELL32 - "Microsoft
Shell Controls and Automation".

--
Jim Rech
Excel MVP


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Need a "GetFolder method"

John Walkenbach shows you how to display the standard folders selection
dialog - sample code at:

http://j-walk.com/ss/excel/tips/tip29.htm
Selecting a directory

If you want to start from a specific location as the pre-selection, you can
use a more complex version provided by Jim Rech on Stephen Bullen's site on
the MVP page.

http://www.BMSLtd.co.uk/MVP/default.htm


Regards,
Tom Ogilvy


"Helge V. Larsen" wrote in message
...
I have used the "GetSaveAsFilename method" to let the user give a file

name.
But now I need a "GetFolder method" that will let the user give a folder
name. The "GetFolder method" does not exist in VBA. Has anyone programmed
something that can do the trick ? - or can you give me a hint on how to do
it ?




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default Need a "GetFolder method"

John has some code for allowing users to select a directory.

John Walkenbach : Selecting a Directory
http://j-walk.com/ss/excel/tips/tip29.htm

HTH
Paul
--------------------------------------------------------------------------------------------------------------
Be advised to back up your WorkBook before attempting to make changes.
--------------------------------------------------------------------------------------------------------------

I have used the "GetSaveAsFilename method" to let the user give a file name.
But now I need a "GetFolder method" that will let the user give a folder
name. The "GetFolder method" does not exist in VBA. Has anyone programmed
something that can do the trick ? - or can you give me a hint on how to do
it ?




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Need a "GetFolder method"

FYI, Helge, the advantage of using the download that Chip cited is that it
lets you preselect a specific folder when you show the dialog box. This is
good if say you're asking the user for a "data save folder" and you want to
default it to his current choice.

The advantage of the Shell API route is that (1) it is far simpler and (2)
you can set a "root" folder (like C:\). The download doesn't let you do
this because I never figured out how<g.

--
Jim Rech
Excel MVP


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
"Object doesn't support this property or method" in Excel 2003 rhiski12 Excel Discussion (Misc queries) 3 November 24th 08 03:58 PM
"Select method of Range class failed" Error Ayo Excel Discussion (Misc queries) 3 September 2nd 08 07:58 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
"Run-time error '1004'" Method 'Range' of object '_global' failed. haisat[_2_] Excel Programming 0 October 20th 03 12:13 PM
"Select Column method or property not available because some/all of object doesn't refer to table" Steven Rosenberg Excel Programming 0 August 18th 03 04:41 AM


All times are GMT +1. The time now is 09:05 PM.

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"