+ Reply to Thread
Results 1 to 7 of 7

how to get a hardisk serial number anad change it if the file moved to another hardisk

Hybrid View

  1. #1
    Registered User
    Join Date
    08-16-2018
    Location
    Purwokerto, Indonesia
    MS-Off Ver
    16
    Posts
    8

    how to get a hardisk serial number anad change it if the file moved to another hardisk

    hi all,
    I want to ask, how to get the hard drive serial value recorded in cell a1 then if the file is moved to another hard drive then the serial hard disk follows the location of the file, thank you

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,446

    Re: how to get a hardisk serial number anad change it if the file moved to another hardisk

    .
    Paste in Routine Module :

    Option Explicit
    
    Function HdNum() As String
        Dim fsObj As Object
        Dim drv As Object
        Set fsObj = CreateObject("Scripting.FileSystemObject")
        Set drv = fsObj.Drives("C")
        HdNum = Hex(drv.serialnumber)
    End Function
    In any cell, paste this formula : =HdNum()

  3. #3
    Registered User
    Join Date
    08-16-2018
    Location
    Purwokerto, Indonesia
    MS-Off Ver
    16
    Posts
    8
    Quote Originally Posted by Logit View Post
    .
    Paste in Routine Module :

    Option Explicit
    
    Function HdNum() As String
        Dim fsObj As Object
        Dim drv As Object
        Set fsObj = CreateObject("Scripting.FileSystemObject")
        Set drv = fsObj.Drives("C")
        HdNum = Hex(drv.serialnumber)
    End Function
    In any cell, paste this formula : =HdNum()
    Thank you sir. And the name path file's can be changed sir?
    Last edited by jondidi; 08-20-2018 at 07:20 PM.

  4. #4
    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: how to get a hardisk serial number anad change it if the file moved to another hardisk

    Function DriveSerialNumber(sDriveSpec As String) As Long
      ' Returns the serial number of sDriveSpec, which can be
      '  o  a drive letter with optional colon and path separator ("C", "C:", "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
    A
    B
    2
    -557772371
    A2: =DriveSerialNumber("C")
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Registered User
    Join Date
    08-16-2018
    Location
    Purwokerto, Indonesia
    MS-Off Ver
    16
    Posts
    8
    Quote Originally Posted by shg View Post
    Function DriveSerialNumber(sDriveSpec As String) As Long
      ' Returns the serial number of sDriveSpec, which can be
      '  o  a drive letter with optional colon and path separator ("C", "C:", "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
    A
    B
    2
    -557772371
    A2: =DriveSerialNumber("C")
    Thank you sir

  6. #6
    Registered User
    Join Date
    06-04-2018
    Location
    Europe
    MS-Off Ver
    Office365
    Posts
    79

    Re: how to get a hardisk serial number anad change it if the file moved to another hardisk

    @ Logit
    @shg

    Why with your code I get different results?

    Thanks.

  7. #7
    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: how to get a hardisk serial number anad change it if the file moved to another hardisk

    Hex vs decimal.

+ 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. [SOLVED] Help request to change serial number for new date
    By mso3 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-30-2016, 08:05 AM
  2. Incrament serial number up or down using txt file and directory search
    By beenbee in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-29-2014, 08:38 AM
  3. Decrease serial number if matching file found
    By beenbee in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 01-06-2014, 10:30 AM
  4. How to change Serial Number to Text
    By reneesunny in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 11-08-2013, 09:32 PM
  5. Linked File Paths Change When File is Moved
    By belewfripp in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 11-06-2013, 12:18 PM
  6. [SOLVED] can i get back overwriting excel from my hardisk
    By faizal in forum Excel General
    Replies: 1
    Last Post: 07-08-2005, 05:05 AM
  7. automatic new serial number for each new sheet within one file
    By ahmed in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-26-2005, 10:06 AM

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