+ Reply to Thread
Results 1 to 4 of 4

Serial Number of Drive

Hybrid View

  1. #1
    Registered User
    Join Date
    12-13-2014
    Location
    South Central, Texas
    MS-Off Ver
    365
    Posts
    8

    Question Serial Number of Drive

    Is there a simple way to use VBA.Environ$ to get the serial number of the active hard drive?

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2505 Win 11
    Posts
    24,736

    Re: Serial Number of Drive

    Here is a short macro I have used to Dump all environ characteristics. When I ran it a moment ago, it did not show any serial numbers for hard drives.

    Sub ENVIRON_DUMP()
    Dim nCount As Integer
    nCount = 1
        Do Until Environ(nCount) = ""
            Cells(nCount, 1).Value = Environ(nCount)
               nCount = nCount + 1
        Loop
    End Sub
    however a quick google search found the following:

    http://excelexperts.com/getting-hard...-serial-number

    I hope this helps
    Last edited by alansidman; 12-13-2014 at 12:40 PM.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Serial Number of Drive

    Function DriveSerialNumber(sDriveSpec As String) As Long
      ' Returns the serial number of the specified drive
    
      ' sDriveSpec argument can be
      '  o  a drive letter ("C")
      '  o  a drive letter with a colon appended ("C:")
      '  o  a drive letter with a colon and path separator appended ("C:\")
      '  o  a network share specification ("\\computer2\share1")
    
      ' Returns 0 if not found
    
      On Error Resume Next
      DriveSerialNumber = CreateObject("Scripting.FileSystemObject").GetDrive(sDriveSpec).SerialNumber
    End Function
    E.g.,

    MsgBox DriveSerialNumber("C")
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Serial Number of Drive

    Try this line
    Sub ShowHDSerial()
        Range("A1").Value = Hex(CreateObject("Scripting.FileSystemObject").Drives.Item("C:").SerialNumber)
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Get Hard Drive Serial Number?
    By ern2ern in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 01-03-2019, 11:28 PM
  2. Overwrite the advanced filtered data serial number column with unique number
    By krjoshi in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-15-2012, 12:38 AM
  3. Macro to unhide sheets IF macro is enabled and hard drive serial # match list of HD#
    By nikolaikolev in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-24-2011, 01:50 PM
  4. Finding a serial number in a list of serial numbers
    By zocoloco in forum Excel General
    Replies: 2
    Last Post: 02-04-2009, 05:20 AM
  5. [SOLVED] How do I obtain the drive serial number in EXCEL spreadsheet
    By Paul Ramirez in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-03-2005, 06:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1