Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

folder selection dlgbox 2

Status
Not open for further replies.

jbpelletier

Programmer
Sep 8, 2001
232
CA
hi

i need something like this
: Application.GetOpenFilename
but to select a folder with office 97/
in access and excel vba

jb
 
This what I personally use:
Code:
Function PickFolder(strStartDir As Variant) As String
    Dim SA As Object, f As Object
    Set SA = CreateObject("Shell.Application")
    Set f = SA.BrowseForFolder(0, "Choose a folder", 0, strStartDir)
    If (Not f Is Nothing) Then
        PickFolder = f.Items.Item.Path
    End If
    Set f = Nothing
    Set SA = Nothing
End Function

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV : when i try your code and it says error: an active x control cannot create an object

do i miss something? do i need to add a reference?

RoyVidar: i tried the "BrowseFolder Dialog" link and under excel it works but it open access and after i can't close it excep with ctrl+alt+grrr . Havent try it under acess but i guess it will work.

tanx
jb



 
nv i got it

change
.hOwner = hWndAccessApp
with
.hOwner = hWndexcelApp

tanx
jb
 
an active x control cannot create an object
And which line of code is highlighted in debug mode ?
From the official site (Minimum DLL version shell32.dll version 4.71 or later
Minimum operating systems Windows 2000, Windows NT 4.0 with Internet Explorer 4.0, Windows 98, Windows 95 with Internet Explorer 4.0

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV: it was this line
>> Set SA = CreateObject("Shell.Application")

btw i havent tryied under acces so far, i have only tried under excel 97


jb
 
For me, works on all the VBA containers.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top