LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Computer Identification using VBA in Excel

Hi David,
With CreateObject("WScript.Network")
MsgBox "Domain = " & .UserDomain & vbLf _
& "Computer Name = " & .ComputerName & vbLf _
& "User Name = " & .UserName
End With

MP

"David Hall" a écrit dans le message de
...
Hi

A bit of a challenging problem here as a previously
provided solution (that seemed excellent to me) doesn't
quite provide the right answer.

I would like to setup a macro within Excel that checks
which computer is using a particular Excel Doc.

Is there a command that gets the computer's "Hard Disc
Serial Number" or any other unique reference number that
identifies the particular computer ?

An earlier posting provided the following codes - which
unfortunately give the same answer on different computers
that have the same manufacturer and are the same model:

One way: Get the serial number of your harddisk. Find
below two
solutions:

1. Using the Windows Scripting Host (a repost from Bob
Phillips):
Function DiskVolumeId() As String
Dim FSO As Object

Set FSO = CreateObject("Scripting.FileSystemObject")
DiskVolumeId = Format(CDbl(FSO.Drives("C:").SerialNumber))
End Function

2. Or using API calls (if for example WSH is not
available):
Declare Function GetVolumeInformation Lib "kernel32" Alias
_
"GetVolumeInformationA" (ByVal lpRootPathName As String,
ByVal _
lpVolumeNameBuffer As String, ByVal nVolumeNameSize As
Long, _
lpVolumeSerialNumber As Long, lpMaximumComponentLength As
Long, _
lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As
String, _
ByVal nFileSystemNameSize As Long) As Long

Function get_drive_serial()
Const cMaxPath = 256, cDrive = "C:\"
Dim lngtemp
Dim strTemp As String, lngRet As Long
Dim lngVolSerial As Long, strVolName As String *
cMaxPath
Dim lngMaxCompLen As Long, lngFileSysFlags As Long
Dim strFileSysName As String * cMaxPath

lngRet = GetVolumeInformation(cDrive, strVolName,
cMaxPath, _
lngTemp, lngMaxCompLen, lngFileSysFlags,
strFileSysName, _
cMaxPath)
strTemp = Format(Hex(lngTemp), "00000000")
strTemp = Left(strTemp, 4) & "-" & Right(strTemp, 4)

get_drive_serial = strTemp
End Sub


I use Excel 2003, and I am trying to find a way of
limiting the use of a particular Excel Doc to certain
users.

Many thanks for your input and comments

David Hall



 
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
Formulaed cell response varies from computer to computer WKH Excel Discussion (Misc queries) 3 November 21st 07 06:37 PM
Excel column identification EngineerOldie Setting up and Configuration of Excel 2 March 15th 06 08:26 PM
How do I copy all Excel files from old computer to new computer? Rfarsh Excel Discussion (Misc queries) 2 December 20th 05 03:23 AM
Excel version identification from Visual Basic Raja Ranga Excel Discussion (Misc queries) 6 January 17th 05 08:48 PM
Computer identification using Excel VB Dvid Hall Excel Programming 8 May 30th 04 05:37 PM


All times are GMT +1. The time now is 06:23 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"