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
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
.
Paste in Routine Module :
In any cell, paste this formula : =HdNum()![]()
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
![]()
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 -557772371A2: =DriveSerialNumber("C")
Entia non sunt multiplicanda sine necessitate
@ Logit
@shg
Why with your code I get different results?
Thanks.
Hex vs decimal.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks