LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default How do I obtain the drive serial number in EXCEL spreadsheet

Hi Michel,

It certainly looks good to me. Maybe, just to allow for any type of input
(C, C:, C:\, C:\myDir, etc.)

Function DiskVolumeId(Drive As String) As String
Dim sTemp As String
Dim iPos As Long
iPos = InStr(1, Drive, ":")
Drive = IIf(iPos 0, Left(Drive, iPos), Drive & ":")
sTemp = Hex(CreateObject("Scripting.FileSystemObject") _
.Drives.Item(CStr(Drive)).SerialNumber)
DiskVolumeId = Left(sTemp, 4) & "-" & Right(sTemp, 4)
End Function

Regards

Bob

"Michel Pierron" wrote in message
...
Hi Bob,
If you agree, I prefer:

Function DiskVolumeId(Drive As String) As String
DiskVolumeId = Hex(CreateObject("Scripting.FileSystemObject") _
.Drives.Item(CStr(Drive)).SerialNumber)
End Function

MP

"Bob Phillips" a écrit dans le message
de news: ...
A couple of ways (to get different answers :-))


'Using FSO

Function DiskVolumeId(Drive As String) As String
Dim FSO As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
DiskVolumeId = Format(CDbl(FSO.Drives(Drive).SerialNumber))
End Function


snip


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Paul Ramirez" wrote in message
m...
How can I obtain the serial number of a drive that a spreadsheet is
installed on from within the same EXCEL spreadsheet?









 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Look up part of a number within a serial number and cpy back assoc Seantastic Excel Worksheet Functions 9 November 3rd 08 04:10 PM
Obtain row number of active cell Jive Excel Worksheet Functions 4 January 8th 08 01:06 PM
Obtain drive letter assignment of CD/DVD drive? EagleOne Excel Discussion (Misc queries) 1 October 13th 06 01:27 PM
Insert auto serial number in Excel template Van Gel Excel Programming 1 February 18th 05 01:33 PM


All times are GMT +1. The time now is 07:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"