![]() |
VBA Code return value in Excel
Hello, I am trying to run the following code to return the serial number of
the hard drive i.e. a unique identifier . is it possible to amend this code to return the serial number as a value in a particular excel cell? Thanks very much for your help Sub SerialNumber() Dim oFSO As Object Dim drive As Object Set oFSO = CreateObject("Scripting.FileSystemObject") Set drive = oFSO.GetDrive("C:\") MsgBox drive.SerialNumber Set oFSO = Nothing Set drive = Nothing 'release memory End Sub |
VBA Code return value in Excel
not sure from your question if this is what you want or not
Sub SerialNumber() Dim oFSO As Object Dim drive As Object Set oFSO = CreateObject("Scripting.FileSystemObject") Set drive = oFSO.GetDrive("S:\") Worksheets("Sheet1").Range("A1").Value = "'" & drive.SerialNumber Set oFSO = Nothing Set drive = Nothing 'release memory End Sub -- Gary "Blair" wrote in message ... Hello, I am trying to run the following code to return the serial number of the hard drive i.e. a unique identifier . is it possible to amend this code to return the serial number as a value in a particular excel cell? Thanks very much for your help Sub SerialNumber() Dim oFSO As Object Dim drive As Object Set oFSO = CreateObject("Scripting.FileSystemObject") Set drive = oFSO.GetDrive("C:\") MsgBox drive.SerialNumber Set oFSO = Nothing Set drive = Nothing 'release memory End Sub |
VBA Code return value in Excel
Yes this is exactly what I wanted. Thank you for your help.
"Gary Keramidas" wrote: not sure from your question if this is what you want or not Sub SerialNumber() Dim oFSO As Object Dim drive As Object Set oFSO = CreateObject("Scripting.FileSystemObject") Set drive = oFSO.GetDrive("S:\") Worksheets("Sheet1").Range("A1").Value = "'" & drive.SerialNumber Set oFSO = Nothing Set drive = Nothing 'release memory End Sub -- Gary "Blair" wrote in message ... Hello, I am trying to run the following code to return the serial number of the hard drive i.e. a unique identifier . is it possible to amend this code to return the serial number as a value in a particular excel cell? Thanks very much for your help Sub SerialNumber() Dim oFSO As Object Dim drive As Object Set oFSO = CreateObject("Scripting.FileSystemObject") Set drive = oFSO.GetDrive("C:\") MsgBox drive.SerialNumber Set oFSO = Nothing Set drive = Nothing 'release memory End Sub |
All times are GMT +1. The time now is 01:25 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com