Solved

Open windows explorer on a CD from a form button

Posted on 2004-09-13
7
272 Views
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:

On_Click

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:

On_Click

"Open CDROM with explorer.exe"

Thanks.

/.nick
0
Comment
Question by:Anjinsan5
7 Comments
 
LVL 67

Accepted Solution

by:
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...
0
 
LVL 8

Assisted Solution

by:mladenovicz
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
    Next
   
    Set oFSO = Nothing
End Sub
0
 
LVL 8

Expert Comment

by:mladenovicz
ID: 12043356
You will need reference to Microsoft Scripting runtime
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:Anjinsan5
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.

/.nick
0
 
LVL 7

Assisted Solution

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

shell("explorer g:") for example.

i.e shell ("explorer " & strCDLetter)
0
 

Author Comment

by:Anjinsan5
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...
0
 

Author Comment

by:Anjinsan5
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!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now