How can a HDD serial# locate a Drive?

MPW

Well-known Member
Joined
Oct 7, 2009
Messages
571
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I am using Excel 2003 to backup files automatically to 2 external drives.
The user initially selects the drives for the project to reside on. Since these removable drives could be unplugged and reattached, there is a strong chance that they will have different drive letters assigned.

Instead of requiring the user to continually browse for the drive I would like to use the HDD serial number (since it will never change) to locate the target and copy the files. I know that I could loop through the drives but I would rather just use the copy command.
Example: FileCopy "C:\Original_File", "E:\Copied_File"

My question is how do I write the command using the serial number instead of the drive letter.
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Can get path and serial number like this :
Code:
'========================================================================================
'- GET EXTERNAL HARD DRIVES (includes flash drives)
'========================================================================================
Sub GET_EXTERNAL_DRIVES()
    Dim FSO, Drive, Counter
    '------------------------------------------------------------------------------------
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Counter = 0
    '------------------------------------------------------------------------------------
    '- LOOP ALL DRIVES
    For Each Drive In FSO.drives
        If Drive.isready And Drive.drivetype = 1 Then
            Counter = Counter + 1
            MsgBox ("Path   :  " & Drive.Path & "\" & vbCr _
                  & "Serial : " & Drive.serialnumber)
        End If
    Next
    '------------------------------------------------------------------------------------
    MsgBox ("Found " & Counter & " external drive(s).")
End Sub
'========================================================================================
 
Upvote 0
Thanks Brian,

I had decided to go with a For Loop to match up the pre-selected Serial number. Once it finds the number I just wrote the FileCopy command as usual. I did like the way you wrote the For Loop, it was a little more straight forward then what I have been using.

Mark
 
Upvote 0

Forum statistics

Threads
1,214,627
Messages
6,120,610
Members
448,973
Latest member
ChristineC

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top