Display a select folder dialog box in VB6
Takeaway: VB6's Microsoft Shell and Automation Component allows you to select a folder. Follow Peter Aitken's instructions in this tip to learn how to show a particular folder's dialog box.
VB6's Common Dialog control makes it easy to let the user select a file, but what about selecting a folder? This is also easy to do with the Microsoft Shell and Automation component.
First, add a reference to this component, which is located in Shell32.dll, to your project. You'll also need declarations in your code. View Listing A to see the declarations.
Then create an instance of the Shell class:
Set shlShell = New Shell32.Shell
Finally, display the dialog box and return the result:
Set shlFolder = shlShell.BrowseForFolder(Me.hWnd, "Select a Folder", _
BIF_RETURNONLYFSDIRS)
Now the selected folder is available in the property shlFolder.Title.
Miss a tip?
Check out the Visual Basic archive, and catch up on the most recent editions of Peter Aitken's column.
Advance your scripting skills to the next level with TechRepublic's free Visual Basic newsletter, delivered each Friday. Automatically sign up today!
Print/View all Posts Comments on this article
SponsoredWhite Papers, Webcasts, and Downloads
- Disaster Recovery Simplified: iSCSI and VMware Site Recovery Manager Deliver Results Dell EqualLogic
- Virtualization and Disk Performance Diskeeper
- Prescription for Growth: Dell storage helps Navicure reduce disaster recovery site deployment time by 75 percent Dell EqualLogic
- Architecting the Virtual Data Center for Availability, Data Protection, and Disaster Recovery Dell EqualLogic
- Live Webcast: Enterprise Search Architectures of the Future Google
Article Categories
- Security
- Security Solutions, IT Locksmith
- Networking and Communications
- E-mail Administration NetNote, Cisco Routers and Switches
- CIO and IT Management
- Project Management, CIO Issues, Strategies that Scale
- Desktops, Laptops & OS
- Windows 2000 Professional, Microsoft Word, Microsoft Excel, Microsoft Access, Windows XP,
- Data Management
- Oracle, SQL Server
- Servers
- Windows NT, Linux NetNote, Windows Server 2003
- Career Development
- Geek Trivia
- Software/Web Development
- Web Development Zone, Visual Basic, .NET

