473,386 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Folder?

Hi All,

I want to browse to a particular folder, not a particular file.

The reason for this is that I have a utility that asks people to browse
to a certain file, and I want them to be able to choose the location
that they start browsing.

Thanks in advance.

Regards,

Nick

Jul 31 '06 #1
9 3677
You can call the Windows Browse Filter dialog:
http://www.mvps.org/access/api/api0002.htm

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Nick 'The Database Guy'" <ni*****@btinternet.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
Hi All,

I want to browse to a particular folder, not a particular file.

The reason for this is that I have a utility that asks people to browse
to a certain file, and I want them to be able to choose the location
that they start browsing.

Thanks in advance.

Regards,

Nick

Jul 31 '06 #2
I've tried that one and it insists on showing a list of folders not filters,
what am I doing wrong ??

<g>

--

Terry Kreft
"Allen Browne" <Al*********@SeeSig.Invalidwrote in message
news:44**********************@per-qv1-newsreader-01.iinet.net.au...
You can call the Windows Browse Filter dialog:
http://www.mvps.org/access/api/api0002.htm

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Nick 'The Database Guy'" <ni*****@btinternet.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
Hi All,

I want to browse to a particular folder, not a particular file.

The reason for this is that I have a utility that asks people to browse
to a certain file, and I want them to be able to choose the location
that they start browsing.

Thanks in advance.

Regards,

Nick


Jul 31 '06 #3
Thanks for pointing that out Allen.

Cheers,

Nick

Allen Browne wrote:
You can call the Windows Browse Filter dialog:
http://www.mvps.org/access/api/api0002.htm

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Nick 'The Database Guy'" <ni*****@btinternet.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
Hi All,

I want to browse to a particular folder, not a particular file.

The reason for this is that I have a utility that asks people to browse
to a certain file, and I want them to be able to choose the location
that they start browsing.

Thanks in advance.

Regards,

Nick
Jul 31 '06 #4
But I wanted to browse a list of folders. Carrying on from there I
would like to know how I start browsing from a particular location.
Both in a full browser window and in the folder
browser?

Thanks,

Nick

Terry Kreft wrote:
I've tried that one and it insists on showing a list of folders not filters,
what am I doing wrong ??

<g>

--

Terry Kreft
"Allen Browne" <Al*********@SeeSig.Invalidwrote in message
news:44**********************@per-qv1-newsreader-01.iinet.net.au...
You can call the Windows Browse Filter dialog:
http://www.mvps.org/access/api/api0002.htm

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Nick 'The Database Guy'" <ni*****@btinternet.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
Hi All,
>
I want to browse to a particular folder, not a particular file.
>
The reason for this is that I have a utility that asks people to browse
to a certain file, and I want them to be able to choose the location
that they start browsing.
>
Thanks in advance.
>
Regards,
>
Nick
>
Jul 31 '06 #5
I have had some success with the full browser, it is not a complete
success though as the 'File name' box has the last folder of the tree
in it.

Nick

Nick 'The Database Guy' wrote:
But I wanted to browse a list of folders. Carrying on from there I
would like to know how I start browsing from a particular location.
Both in a full browser window and in the folder
browser?

Thanks,

Nick

Terry Kreft wrote:
I've tried that one and it insists on showing a list of folders not filters,
what am I doing wrong ??

<g>

--

Terry Kreft
"Allen Browne" <Al*********@SeeSig.Invalidwrote in message
news:44**********************@per-qv1-newsreader-01.iinet.net.au...
You can call the Windows Browse Filter dialog:
http://www.mvps.org/access/api/api0002.htm
>
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
>
"Nick 'The Database Guy'" <ni*****@btinternet.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
Hi All,

I want to browse to a particular folder, not a particular file.

The reason for this is that I have a utility that asks people to browse
to a certain file, and I want them to be able to choose the location
that they start browsing.

Thanks in advance.

Regards,

Nick

>
>
Jul 31 '06 #6
Nick,
Allen inadvertently typed "Windows Browse Filter" instead of Windows Browse
Folder, I was trying to be amusing.

The code for the browse dialog at the access web doesn't allow you to define
a start folder, you need a call back procedure to do this, the code below
will allow you to define a start folder.

If you go to http://www.mvps.org/access/api/api0001.htm you can download
code which allows you to call the open/save file dialog and allows you to
define a start folder.

'******************************
'Browse Folder Code Start
'******************************
Option Explicit

Private Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As Long
lpszTitle As Long
' lpszTitle As Byte
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type

'******************************
'Functions in BrowseFolder
'******************************
Private Declare Function SHGetPathFromIDList _
Lib "shell32.dll" Alias "SHGetPathFromIDListA" _
(ByVal pidl As Long, ByVal pszPath As String) _
As Long
Private Declare Function SHBrowseForFolder _
Lib "shell32.dll" Alias "SHBrowseForFolderA" _
(lpBrowseInfo As BROWSEINFO) _
As Long
Private Declare Sub ZeroMemory _
Lib "kernel32" Alias "RtlZeroMemory" _
(dest As Long, ByVal numBytes As Long)
Private Declare Function lstrcat _
Lib "kernel32" Alias "lstrcatA" _
(ByVal lpString1 As String, _
ByVal lpString2 As String) _
As Long
'******************************
'/Functions in BrowseFolder
'******************************

Private Declare Function GetFileVersionInfoSize Lib "version.dll" _
Alias "GetFileVersionInfoSizeA" _
(ByVal lptstrFilename As String, _
lpdwHandle As Long) As Long

Private Declare Function GetFileVersionInfo Lib "version.dll" _
Alias "GetFileVersionInfoA" _
(ByVal lptstrFilename As String, _
ByVal dwHandle As Long, _
ByVal dwLen As Long, _
lpData As Any) As Long

Private Declare Function VerQueryValue Lib "version.dll" _
Alias "VerQueryValueA" _
(pBlock As Any, _
ByVal lpSubBlock As String, _
lpBuffer As Any, _
nVerSize As Long) As Long

Private Declare Sub CopyMemory Lib "kernel32" _
Alias "RtlMoveMemory" _
(Destination As Any, _
Source As Any, _
ByVal Length As Long)

'******************************
'Functions used in call back
'******************************
Private Declare Function GetCurrentDirectory _
Lib "kernel32" Alias "GetCurrentDirectoryA" _
(ByVal nBufferLength As Long, _
ByVal lpBuffer As String) _
As Long
Private Declare Function SendMessage _
Lib "user32" Alias "SendMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) _
As Long
'******************************
'/Functions used in call back
'******************************

'******************************
'Root pidls
'******************************
Private Const CSIDL_DESKTOP = &H0
Private Const CSIDL_PROGRAMS = &H2
Private Const CSIDL_CONTROLS = &H3
Private Const CSIDL_PRINTERS = &H4
Private Const CSIDL_PERSONAL = &H5
Private Const CSIDL_FAVORITES = &H6
Private Const CSIDL_STARTUP = &H7
Private Const CSIDL_RECENT = &H8
Private Const CSIDL_SENDTO = &H9
Private Const CSIDL_BITBUCKET = &HA
Private Const CSIDL_STARTMENU = &HB
Private Const CSIDL_DESKTOPDIRECTORY = &H10
Private Const CSIDL_DRIVES = &H11
Private Const CSIDL_NETWORK = &H12
Private Const CSIDL_NETHOOD = &H13
Private Const CSIDL_FONTS = &H14
Private Const CSIDL_TEMPLATES = &H15
'******************************
'Root pidls
'******************************

'******************************
'uFlag consts
'******************************
Private Const BIF_DONTGOBELOWDOMAIN = &H2
Private Const BIF_STATUSTEXT = &H4
Private Const BIF_RETURNFSANCESTORS = &H8
Private Const BIF_BROWSEFORCOMPUTER = &H1000
Private Const BIF_BROWSEFORPRINTER = &H2000
Private Const BIF_RETURNONLYFSDIRS = &H1
Private Const BIF_EDITBOX = &H10
Private Const BIF_VALIDATE = &H20
Private Const BIF_NEWDIALOGSTYLE As Long = &H40
Private Const BIF_USENEWUI As Long = (BIF_NEWDIALOGSTYLE Or BIF_EDITBOX)
'******************************
'/uFlag consts
'******************************

Private Const WM_USER = &H400

'******************************
'Messages from dialog consts
'******************************
Private Const BFFM_INITIALIZED = 1
Private Const BFFM_SELCHANGED = 2
Private Const BFFM_VALIDATEFAILEDA = 3
Private Const BFFM_VALIDATEFAILED = BFFM_VALIDATEFAILEDA
'******************************
'/Messages from dialog consts
'******************************

'******************************
'Messages to dialog consts
'******************************
Private Const BFFM_SETSELECTIONA = WM_USER + 102
Private Const BFFM_SETSELECTION = BFFM_SETSELECTIONA
Private Const BFFM_SETSTATUSTEXTA = WM_USER + 100
Private Const BFFM_SETSTATUSTEXT = BFFM_SETSTATUSTEXTA
'******************************
'/Messages to dialog consts
'******************************

Private Const MAX_PATH = 260

Private strStartDir As String
'

Public Function BrowseFolder(szDialogTitle As String, _
Optional StartDir As String = vbNullString, Optional hWnd As Long = 0) As
String
'*******************************************
'Name: BrowseFolder (Function)
'Purpose: Open API browse for folder dialog
'Author: Terry Kreft
'Date: January 28, 2001, 09:50:20
'Called by: Any
'Calls: AddrOf _
Various API calls defined on this module
'Inputs: szDialogTitle - dialog prompt _
StartDir - Directory to start the _
browse in (Optional)
'Output: Directory selected in browse folder
'*******************************************

Dim x As Long
Dim BI As BROWSEINFO
Dim dwIList As Long
Dim szPath As String
Dim wPos As Integer
Dim lngPtr As Long
Dim bytBuffer() As Byte

strStartDir = StartDir
BrowseFolder = ""

Call ZeroMemory(VarPtr(BI), Len(BI))

' This has to be 1 element larger than the length
' of the string so that it contains the terminating
' Null character
ReDim bytBuffer(0 To Len(szDialogTitle))
For lngPtr = 1 To Len(szDialogTitle)
bytBuffer(lngPtr - 1) = Asc(Mid(szDialogTitle, lngPtr, 1))
Next

With BI
.pidlRoot = CSIDL_DESKTOP
.hOwner = hWnd
.lpszTitle = VarPtr(bytBuffer(0))
.ulFlags = BIF_RETURNONLYFSDIRS Or BIF_STATUSTEXT _
Or BIF_EDITBOX Or BIF_VALIDATE
If IsShellVersion(5) Then
.ulFlags = .ulFlags Or BIF_NEWDIALOGSTYLE
End If
.lpfn = AddrOf2k(AddressOf BrowseCallbackProc)
End With
dwIList = SHBrowseForFolder(BI)
If dwIList Then
szPath = Space$(512)
x = SHGetPathFromIDList(dwIList, szPath)
If x Then
wPos = InStr(szPath, Chr(0))
BrowseFolder = Left$(szPath, wPos - 1)
End If
End If
End Function

Function BrowseCallbackProc(ByVal hWnd As Long, ByVal uMsg As Long, _
ByVal lp As Long, ByVal pData As Long) As Long
'*******************************************
'Name: BrowseCallbackProc (Function)
'Purpose: Call back function for BrowseFolder
'Author: Terry Kreft
'Date: January 28, 2001, 09:52:56
'Called by: API Browse Folder dialog
'Calls: Various API functions
'Inputs: See MSDN for description of inputs
'Output:
'*******************************************
Dim lngRet As Long
Dim nBufferLength As Long
Dim lpBuffer As String

Const apiTrue = 1
Const apiFalse = 0
Const BAD_DIR = "The directory selected is invalid." _
& vbCrLf _
& "Do you want to try again"

lngRet = apiFalse
Select Case uMsg
Case BFFM_INITIALIZED
If Len(strStartDir) < 1 Then
nBufferLength = MAX_PATH
lpBuffer = String(MAX_PATH, 0)
If GetCurrentDirectory(nBufferLength, lpBuffer) Then
Call SendMessage(hWnd, BFFM_SETSELECTION, apiTrue, ByVal lpBuffer)
End If
Else
Call SendMessage(hWnd, BFFM_SETSELECTION, apiTrue, ByVal strStartDir)
End If
Case BFFM_SELCHANGED
'Set the status window to the currently selected path.
lpBuffer = String(MAX_PATH, 0)
If SHGetPathFromIDList(lp, lpBuffer) Then
lpBuffer = Left(lpBuffer, InStr(lpBuffer, Chr(0)) - 1)
Call SendMessage(hWnd, BFFM_SETSTATUSTEXT, apiTrue, ByVal lpBuffer)
End If
Case BFFM_VALIDATEFAILED
'If the user types an invalid path
If MsgBox(BAD_DIR, vbYesNo) = vbYes Then
lngRet = apiTrue
End If
' Case BFFM_IUNKNOWN

Case Else
Debug.Print uMsg
End Select
BrowseCallbackProc = lngRet
End Function

Function AddrOf2k(ByVal lngFnPtr As Long) As Long
AddrOf2k = lngFnPtr
End Function

Private Function IsShellVersion(ByVal Version As Long) As Boolean

'returns True if the Shell version
'(shell32.dll) is equal or later than
'the value passed as 'version'
Dim nBufferSize As Long
Dim nUnused As Long
Dim lpBuffer As Long
Dim nVerMajor As Integer
Dim bBuffer() As Byte

Const sDLLFile As String = "shell32.dll"

nBufferSize = GetFileVersionInfoSize(sDLLFile, nUnused)

If nBufferSize 0 Then

ReDim bBuffer(nBufferSize - 1) As Byte

Call GetFileVersionInfo(sDLLFile, 0&, nBufferSize, bBuffer(0))

If VerQueryValue(bBuffer(0), "\", lpBuffer, nUnused) = 1 Then

CopyMemory nVerMajor, ByVal lpBuffer + 10, 2

IsShellVersion = nVerMajor >= Version

End If 'VerQueryValue
End If 'nBufferSize

End Function

'******************************
'Browse Folder Code Start
'******************************
--

Terry Kreft
"Nick 'The Database Guy'" <ni*****@btinternet.comwrote in message
news:11*********************@s13g2000cwa.googlegro ups.com...
But I wanted to browse a list of folders. Carrying on from there I
would like to know how I start browsing from a particular location.
Both in a full browser window and in the folder
browser?

Thanks,

Nick

Terry Kreft wrote:
I've tried that one and it insists on showing a list of folders not
filters,
what am I doing wrong ??

<g>

--

Terry Kreft
"Allen Browne" <Al*********@SeeSig.Invalidwrote in message
news:44**********************@per-qv1-newsreader-01.iinet.net.au...
You can call the Windows Browse Filter dialog:
http://www.mvps.org/access/api/api0002.htm
>
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
>
"Nick 'The Database Guy'" <ni*****@btinternet.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
Hi All,

I want to browse to a particular folder, not a particular file.

The reason for this is that I have a utility that asks people to
browse
to a certain file, and I want them to be able to choose the location
that they start browsing.

Thanks in advance.

Regards,

Nick

>
>

Jul 31 '06 #7
Nick 'The Database Guy' wrote:
Hi All,

I want to browse to a particular folder, not a particular file.

The reason for this is that I have a utility that asks people to browse
to a certain file, and I want them to be able to choose the location
that they start browsing.

Thanks in advance.

Regards,

Nick
From:
http://msdn.microsoft.com/library/de.../folder_id.asp

"When the user selects a folder, SHBrowseForFolder returns the folder's
fully-qualified PIDL..."

So if your default folder is not going to change you could pick the
folder you want to be the default, return the PIDL using
SHBrowseForFolder, then use that PIDL to set the default folder in the
BROWSEINFO structure. I have tried this and it works well. If the
default folder needs to be changed at will then I believe the addition
of that flexibility can be found here:

http://www.lebans.com/callbackbrowser.htm

James A. Fortune
CD********@FortuneJames.com

Jul 31 '06 #8
My thanks go out to James and all other who posted a response.

CD********@FortuneJames.com wrote:
Nick 'The Database Guy' wrote:
Hi All,

I want to browse to a particular folder, not a particular file.

The reason for this is that I have a utility that asks people to browse
to a certain file, and I want them to be able to choose the location
that they start browsing.

Thanks in advance.

Regards,

Nick

From:
http://msdn.microsoft.com/library/de.../folder_id.asp

"When the user selects a folder, SHBrowseForFolder returns the folder's
fully-qualified PIDL..."

So if your default folder is not going to change you could pick the
folder you want to be the default, return the PIDL using
SHBrowseForFolder, then use that PIDL to set the default folder in the
BROWSEINFO structure. I have tried this and it works well. If the
default folder needs to be changed at will then I believe the addition
of that flexibility can be found here:

http://www.lebans.com/callbackbrowser.htm

James A. Fortune
CD********@FortuneJames.com
Aug 1 '06 #9
others *

CD********@FortuneJames.com wrote:
Nick 'The Database Guy' wrote:
Hi All,

I want to browse to a particular folder, not a particular file.

The reason for this is that I have a utility that asks people to browse
to a certain file, and I want them to be able to choose the location
that they start browsing.

Thanks in advance.

Regards,

Nick

From:
http://msdn.microsoft.com/library/de.../folder_id.asp

"When the user selects a folder, SHBrowseForFolder returns the folder's
fully-qualified PIDL..."

So if your default folder is not going to change you could pick the
folder you want to be the default, return the PIDL using
SHBrowseForFolder, then use that PIDL to set the default folder in the
BROWSEINFO structure. I have tried this and it works well. If the
default folder needs to be changed at will then I believe the addition
of that flexibility can be found here:

http://www.lebans.com/callbackbrowser.htm

James A. Fortune
CD********@FortuneJames.com
Aug 1 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: jenny | last post by:
Hi, I am trying to find a VB way that would create a folder on all existing drives - the folder name would be the same on each drive. ie c:\backup, d:\backup, etc. But the folders would only be...
7
by: Tom | last post by:
Can anyone give me any advice on how to secure a folder on a network server so that documents in the folder can only be opened through an Access database or by the database admin. I need to store...
0
by: John H. | last post by:
In effort to understand (Outlook) MAPI folder tree structure wrote simple linear code below to navigate tree. Successive "...Folders.GetNext()"'s return same folder at all levels of tree. What...
4
by: Dave Veeneman | last post by:
I'm puzzling over the best design for a Folder object. I have two basic domain objects; leat's call them an Apple and an Orange. The objects are maintained in separate hierarchies, and each...
8
by: vinesh | last post by:
I have sample Asp.Net Web Application project. Let me know how to keep the files related to this project (like the webform.aspx, WebForm1.aspx.vb, WebForm1.aspx.resx) in a separate folder within a...
9
by: Paul | last post by:
I'm trying to make get my app to delete all the files in a specified folder and all the files within the folders of the specified folder. e.g. Folder 1 contains three files (File1, File2, File3)...
2
by: tatemononai | last post by:
Ok, this is a very unique bug. I have only been able to find one other post related to this online, and everybody who responded misunderstood the problem. I am not trying to reference anything in...
17
by: rdemyan via AccessMonster.com | last post by:
With A2003, I'm having trouble accessing files in a folder on another computer where back-end files, update files, etc are located. Here's the scenario: 1) Computer #1 - A2003 2) Computer #2 -...
24
by: biganthony via AccessMonster.com | last post by:
Hi, I have the following code to select a folder and then delete it. I keep getting a Path/File error on the line that deletes the actual folder. The line before that line deletes the files in...
5
by: Noozer | last post by:
I'm looking for a "smart folder" program to run on my Windows XP machine. I'm not having any luck finding it and think the logic behind the program is pretty simple, but I'm not sure how I'd...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.