View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jake Marx[_3_] Jake Marx[_3_] is offline
external usenet poster
 
Posts: 860
Default Function GetActiveWindow Lib "user32"

Hi Jac,

You have a few options here. If you want to be able to specify the initial
folder, you can automate the Shell interface to do it:

Sub test()
Dim sh As Object
Dim fol As Object
Dim fi As Object

Set sh = CreateObject("Shell.Application")

Set fol = sh.BrowseForFolder(Application.Hwnd, _
"Select Folder", 0, "C:\")

If Not fol Is Nothing Then
Set fi = fol.ParentFolder.ParseName(fol.Title)
If Not fi Is Nothing Then
MsgBox fi.Path
Else
MsgBox fol.Title
End If
Set fol = Nothing
Else
MsgBox "no folder selected"
End If
End Sub

Alternatively, you can utilize the API using Jim Rech's Browse For Folder
utility:

http://bmsltd.ie/MVP/Default.htm (look for BrowseForFolder.zip under Jim
Rech's name)

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Jac Tremblay wrote:
Hi everyone,
When we use this Windows API, the default "Folder" (it's not really a
folder) that is selected in the window that appears is the user's
workstation. Is there a way to change that default value to a known
folder or to a specific path so that the user does not have to click
many times to reach the desired path. I do not include any code, but
it is all available if any one needs it. You just have to ask for it.
Thank you.