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?
 
Hi

I have a little problem. I am writing a macro which can run in four different PC namely DELL,ACER,HCL,LENOVO.
The macro will open a file and execute a certain function, the real problem is the location of this file. The location of the file is different in all the four system make.

Can anyone help me?

(I have written four different macro for this, can this be made into one macro by detecting the system manufacturer and choosing the corresponding path to open the file)

Thanks in advance
 
Upvote 0

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
What happens if the licensee gets rid of his original laptop\PC and buys a new one?
 
Upvote 0
What happens if the machine breaks down and you want to install the software or file on a new machine?
 
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
please if i have two computers and insert two serial number how i can write the code thanks
 
Upvote 0

Forum statistics

Threads
1,215,771
Messages
6,126,799
Members
449,337
Latest member
BBV123

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