Recently I wanted to launch Windows Explorer opening a specified folder. I tried searching Google and did not find any VB code so I did a little research, modified some code I'd previously written and was able to accomplish the task. I created class 'cLaunchExplorer'. I made the class code available as a tip in November 2004.
I wrote a VB6 demo program to illustrate the use of the class. The demo:
Folder - Enter the folder to be opened. Default is App.Path.
Browse Button - Click the browse button to search for a folder.
Explorer Format - Check this box if you want to open the folder using the "Explore" format.
Open... - Click this button to open the folder. The button's caption changes based upon the Explorer Format option selected.
Dim objLaunchExplorer As New cLaunchExplorer
If Me.Check1.Value = vbChecked Then 'which format
.bExplorerFormat = True
.sPath = Me.Text1.Text 'folder to open
.Launch 'do it
Properties and Methods
Methods/Properties Operands Sample .Launch [sPath][,bExplorerFormat] .Launch .sPath Folder to be opened .sPath = "C:\" .bExplorerFormat True/False .bExplorerFormat = True
The Demo Program Uses These Modules
Module - Click for More Info Description Used in the Demo To cLaunchExplorer.cls Launch Windows Explorer The subject of this tip.
Include in your application.
Browse for a Folder Browse for a folder. modAddBackSlash.bas Add a Backslash if Needed Add a backslash to App.Path, if needed. modConnectToWebSite.bas Connect to a web site Show this info when Help/Info is
selected from the demo.
modInfoAbout.bas DoInfo, DoAbout, DoTip Link to this page and provide helpful information
Code is Based Upon function OpenURL
I based the code used in cLaunchExplorer on function OpenURL used in modConnectToWebSite - see above.
Download VB Code
Click here to download the VB 6 source code [11k].
Previous Tip Tip Index Next Tip