VBA Code To Do Check for a Valid Use Computer

spurs

Active Member
Joined
Oct 18, 2006
Messages
479
Office Version
  1. 2016
  2. 2013
  3. 2010
  4. 2007
  5. 2003 or older
Platform
  1. Windows
I want to incorporate into my VBA code a check to make sure that the computer that the VBA code is being run on is authorized for use.

Is there a unique serial number - that VBA can access to verify that the computer being used is in fact authorized for use? - Possibly a serial number that identifies a specific drive, or motherboard or some other feature? My plan would be that this number would be hard coded into the VBA code and everytime the program is run, it would shut down if the number does not match the allowable number.

Is there a down side to this approach? I am writing code that is to be used on only a handful of authoized computers, and I am trying to prevent the code from being used malicously elsewhere.

What is the VBA code that is needed to get this number from a system?
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
I think you can make a lincense file and make the excel only run if lincense is found.

If that will fix your problem, ill try to make an eg. if it's possible. but i think so :)
 
Last edited:
Upvote 0
This may get you started, this code is placed in a userform initialize event;

Code:
Private Sub UserForm_Initialize()
'sHost is a label that gives the PC name
sHostName.Caption = Environ$("computername")
'sUserName is a label that gives the user name
sUserName.Caption = Environ$("username")
End Sub

All it does is show the PC name and the username, you will have to adapt it to suit your purpose.

HTH
Colin
 
Upvote 0
Matsgroe

Yes I would like to see what such a license file would look like. I am particularly interested in how to read the serial number information that is unique to the particular hardware.

RS2K - The use of the computer name would not be secure enough since this is something that the user would be able to change. I am hoping to use some sort of internal serial number that VBA can read from either the hard drive or motherboard or some sort of unique identifier.

In fact I will need to create 2 files. One will be a simple program to get the information for me the first time so that I can embed the code into VBA. The second will be the actual License file as Mastsgroe suggests.

Thanks
 
Upvote 0
Why not just password protect the book, and only give the password to authorized users?

Don't say "Because passwords can be hacked"...
Becuase Anything can be hacked.

Excel just is not a very secure environment.
 
Upvote 0
Jonmo1

I have develped a unique piece of software for a company to incorporate in the build of their machines.

By using a licence file, it is easier to track each machine that the software has been licensed to for verification that all fees have been properly paid.

Just giving the machine builder the passwords defeats that purpose
 
Upvote 0
Hello: This code gets the HD #
Code:
 Option Explicit
 
Sub DriveSerialNumber()
    MsgBox CreateObject("Scripting.FileSystemObject").GetDrive("C:\").SerialNumber
End Sub

And this code verifies the serial number and opens the file if the serial number checks out
Code:
Private Sub Workbook_Open()
If CreateObject("Scripting.FileSystemObject").GetDrive("C:\").SerialNumber <> "-1464624812" Then Application.Quit
End Sub

Your HD might or might not have a minus sighn in front of the number... if it does make sure you include it.


just noticed that jonmo1 posted .. sorry for this
 
Last edited:
Upvote 0
This worked great

Thank you all
 
Upvote 0

Forum statistics

Threads
1,215,110
Messages
6,123,139
Members
449,098
Latest member
Doanvanhieu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top