Thank you very much - but it does not help me. I am not able to re-write your c++ example to VBA. No matter what I do, it get syntax errors and compile erros.
Main Topics
Browse All TopicsIn a Excel sheet I have a commandbutton with the text "Select folder", where I want to select a certain root folder, and store the information of the selected subfolder for later use.
By searching the net I found the VBA code shown in the Code section (displays the common dialog Select folder), and it works fine. BUT I want to display the Select folder dialog with a specific root folder on a network, not the Desktop. I then searched again and found some information about the ILCreateFromPath function which should return some kind of structure to use with the pidlRoot property of the SHBrowseForFolder method/function. But I can't find a full VBA example anywhere, that shows me how to build the code from A to Z. And as I am not familiar with this kind of code I can't use my usual Word VBA logic. I have spent hours trying out different things, but nothing works. I am pretty sure it is very easy for someone who knows averything about common dialogs :-).
So.... can anyone take the code example shown in the Code section and re-write it for me, so that I can display a Select Folder dialog with any folder of my own choice as default root folder? For testpurposes it could be "C:\Officesolutions\MyFile
Thank you all very much in advance.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hello Dan,
Thank you for replying to me again. I can see what you mean and the difference. Sorry, I am Danish, so it is sometimes a challenge to find the right phrases in English. I have viewed the article, and there is no doubt: I want to pre-set an initial folder - a default folder - as shown in the first screendump in the article. So that the user does not have to browse 3-5 levels down in a network folder to get to the right main folder - All Departments - on the server.
I you can translate such a code example to VBA, I would be very grateful, and I have increased the points to 500.
I really can't translate (the AddressOf thing is non-standard for VBA, but normal and easy in C++), but I found some code and played around with it until it seemed to work (I tried it in an MsWord macro)
I just hard-coded an example pathname... strStartFolder you should be able to pass it in as a parameter
Original source was pieced together from various posts here:
http://www.vbcode.com
and here:
http://www.bigresourc
Business Accounts
Answer for Membership
by: DanRollinsPosted on 2009-09-20 at 02:47:06ID: 25376467
Here's how to do it in C++
It shouldn't bee too hard to translate that to VBA... it will use the same sort of techniques as in your existing code.
Select allOpen in new window