Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Open windows explorer on a CD from a form button

Posted on 2004-09-13
Last Modified: 2008-03-06
I need the VB code to make it so that I can create an "Explore the CD" button.  I just need to open up the CD in windows explorer for users to be able to browse through the files on it.  I have found things like this:


Shell ("D:" & "\explorer.exe")

but it did not work.  On top of that, I would like to not hard code the CD drive letter, and rather just have it say something like this:


"Open CDROM with explorer.exe"


Question by:Anjinsan5
LVL 67

Accepted Solution

sirbounty earned 350 total points
ID: 12043330
This code will find the cd-rom letter for you: http://www.devdos.com/vb/downloads/cdrom.zip
And then you can
shell ("start " & strCDLetter)
to bring up the explorer window for it...

Assisted Solution

mladenovicz earned 50 total points
ID: 12043349
Private Sub Command1_Click()
Dim oFSO        As Scripting.FileSystemObject
Dim oDrive      As Scripting.Drive
    Set oFSO = New Scripting.FileSystemObject
    For Each oDrive In oFSO.Drives
        If oDrive.DriveType = CDRom Then
            If oDrive.IsReady Then
                Call Shell("explorer.exe " & oDrive.DriveLetter & ":\", vbNormalFocus)
            End If
        End If
    Set oFSO = Nothing
End Sub

Expert Comment

ID: 12043356
You will need reference to Microsoft Scripting runtime
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.


Author Comment

ID: 12043647
sirbounty - tried your solution, but it gives an error "file not found" on this line:

Shell ("start" & justonedrive$)

detected the drive letter just fine, but won't open up windows explorer.


Assisted Solution

_agj_ earned 100 total points
ID: 12043744
u can use:

shell("explorer g:") for example.

i.e shell ("explorer " & strCDLetter)

Author Comment

ID: 12043766
thanks agj, that seems to have worked, now my only question is how to make sure that the explorer window has focus when it opens...

Author Comment

ID: 12043803
never mind, i got it.  Simply used the info above and wrote:

Call Shell("explorer " & justonedrive$, vbNormalFocus)

works like a charm...thanks so much everybody!

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question