Browse for folder (but with shortcuts)

R

rob

I would like to select a folder and use BrowseForFolder.
This works fine but does not show the shortcuts so that I browse through
these.

Anyone an idea that allows me to work with shortcuts as well to get to my
final directory destination?
 
J

joel

Below is the method using the Win32 DLL. If htis can't get what you ar
looking for then you would have to create you own listbox and put th
w\items you are looking for into the list box.

Here is the microsoft website library definition.

'SHBrowseForFolder Function ()
(http://msdn.microsoft.com/en-us/library/bb762115(VS.85).aspx)

There is a paragraph in the above website the talks about SHORTCUT.


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

Private Declare Function SHBrowseForFolder Lib "shell32.dll" Alias _
"SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) _
As Long

Sub test()

Dim bi As BROWSEINFO
Dim dwIList As Long

dwIList = SHBrowseForFolder(bi)

End Su
 
J

joel

Just put the posted code into VBA in Excel and run. Include everything
in my posting incling the library definition and Private Type BROWSEINFO
 
S

Simon Lloyd

*How to add and run a Macro
1. *Copy* the macro
2. Open your workbook
3. Press the keys *ALT+F11* to open the Visual Basic Editor
4. Press the keys *ALT+I* to activate the *Insert menu*
5. *Press M* to insert a *Standard Module*
6. *Paste* the code by pressing the keys *CTRL+V*
7. Make any custom changes to the macro if needed at this time.
8. *Save the Macro* by pressing the keys *CTRL+S*
9. Press the keys *ALT+Q* to exit the Editor, and return to Excel.

*To Run the Macro...*
To run the macro from Excel, open the workbook, and press *ALT+F8* t
display the *Run Macro Dialog*. Double Click the macro's name to *Run
it.

rob;545832 said:
Thanks, but how does this work in VB (excel macro)










Cage Forums' (http://www.thecodecage.com/forumz/showthread.php?t=149959

--
Simon Lloy

Regards
Simon Lloy
'Microsoft Office Help' (http://www.thecodecage.com
 
R

rob

Joel, this is functioning but does NOT list my shortcuts to jump quickly to
my desired directories.
I am looking for a solution that also lists the shortcuts (and allows user
to doubleclick on it).

rob

Simon Lloyd said:
*How to add and run a Macro*
1. *Copy* the macro
2. Open your workbook
3. Press the keys *ALT+F11* to open the Visual Basic Editor
4. Press the keys *ALT+I* to activate the *Insert menu*
5. *Press M* to insert a *Standard Module*
6. *Paste* the code by pressing the keys *CTRL+V*
7. Make any custom changes to the macro if needed at this time.
8. *Save the Macro* by pressing the keys *CTRL+S*
9. Press the keys *ALT+Q* to exit the Editor, and return to Excel.

*To Run the Macro...*
To run the macro from Excel, open the workbook, and press *ALT+F8* to
display the *Run Macro Dialog*. Double Click the macro's name to *Run*
it.

rob;545832 said:
Thanks, but how does this work in VB (excel macro)?


Cage Forums' (http://www.thecodecage.com/forumz/showthread.php?t=149959)


--
Simon Lloyd

Regards,
Simon Lloyd
'Microsoft Office Help' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/showthread.php?t=149959

Microsoft Office Help

.
 
J

joel

That is why I refered you to the SHBrowseForFolder library definition.
The VBA FileDialog is really calling the win32.dll and FileDialog an
SHBrowseForFolder produce the same results. The shortcuts not appearin
is a limitation of the windows operating system.

The website I refered to has references the following webpage (se
BROWSEINFO structure shortcut) which leads to this webiste

'BROWSEINFO Structure ()
(http://msdn.microsoft.com/en-us/library/bb773205(VS.85).aspx)

It seems you have to set the browseinfo to BIF_NEWDIALOGSTYLE. I di
that below. See if this helps. there are other option you may want t
try. Modify as required. You will notice this change allows you t
also resize the window.


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

Private Declare Function SHBrowseForFolder Lib "shell32.dll" Alias _
"SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) _
As Long

Sub test()

Dim bi As BROWSEINFO
Dim dwIList As Long
Const BIF_NEWDIALOGSTYLE As Long = &H40
bi.ulFlags = BIF_NEWDIALOGSTYLE
dwIList = SHBrowseForFolder(bi)

End Su
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top