Prevent worksheet/workbook from being copied

g28days

New Member
Joined
Aug 16, 2018
Messages
7
Hello Excel Experts,

I really in need in your urgent help. I would truly appreciate any pointers or and any help with this code to that will be used to prevent a worksheet/workbook from being copied (shout out to yaseensallam for the code).

#using Excel 2013

This code now works for a single computer, however i would like to add more computer's into the code. How do add in an array or somewhere in those lines to make a list of computers which i can and/delete in future?

HTML:
Private Sub GetSerialNumber()Dim obj As ObjectDim WMI As ObjectDim sAns As StringDim ss As StringDim kk As StringSet WMI = GetObject("WinMgmts:")Set objs = WMI.InstancesOf("Win32_BaseBoard")For Each obj In objs    sAns = sAns & obj.SerialNumber    If sAns < objs.Count Then sAns = sAns & ","Next'GetSerialNumber = sAnsSheets("sheet1").Range("A9") = sAnsEnd Sub

HTML:
Private Sub GetSerialNumberProtection()Dim obj As ObjectDim WMI As ObjectDim sAns As StringDim ss As StringDim kk As StringApplication.DisplayAlerts = Falsess = ".YOURMACHINENAME.           ,"Set WMI = GetObject("WinMgmts:")Set objs = WMI.InstancesOf("Win32_BaseBoard")For Each obj In objs    sAns = sAns & obj.SerialNumber    If sAns < objs.Count Then sAns = sAns & ","Nextkk = sAns If kk <> ss ThenDim answer As IntegerMsgBox "Program Need Maintenance Code 001 .", vbOKOnlyActiveWorkbook.SaveAs FileFormat:=50, Password:="Gordy", WriteResPassword:="", _ReadOnlyRecommended:=False, CreateBackup:=FalseApplication.DisplayAlerts = TrueApplication.QuitEnd If' file format numbers on https://msdn.microsoft.com/en-us/vba...meration-excel'FileFormat:=xlNormal = 56End Sub

HTML:
Private Sub Workbook_Open()Application.ScreenUpdating = False Run "GetSerialNumberProtection" Application.ScreenUpdating = TrueEnd Sub

Thank you so much in advance for taking the time to help me with this. I really x 10000 appreciate it.

regards.,
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Terribly sorry for using HTML codes

Private Sub GetSerialNumber()
Dim obj As Object
Dim WMI As Object
Dim sAns As String
Dim ss As String
Dim kk As String
Set WMI = GetObject("WinMgmts:")
Set objs = WMI.InstancesOf("Win32_BaseBoard")
For Each obj In objs
sAns = sAns & obj.SerialNumber
If sAns < objs.Count Then sAns = sAns & ","
Next
'GetSerialNumber = sAns
Sheets("sheet1").Range("A9") = sAns
End Sub




Private Sub GetSerialNumberProtection()
Dim obj As Object
Dim WMI As Object
Dim sAns As String
Dim ss As String
Dim kk As String
Application.DisplayAlerts = False
ss = ".YOURMACHINE.X1233456. ,"
Set WMI = GetObject("WinMgmts:")
Set objs = WMI.InstancesOf("Win32_BaseBoard")
For Each obj In objs
sAns = sAns & obj.SerialNumber
If sAns < objs.Count Then sAns = sAns & ","
Next
kk = sAns
If kk <> ss Then
Dim answer As Integer
MsgBox "Program Need Maintenance Code 001 .", vbOKOnly
ActiveWorkbook.SaveAs FileFormat:=50, Password:="kumar", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
Application.DisplayAlerts = True
Application.Quit
End If
' file format numbers on https://msdn.microsoft.com/en-us/vba...meration-excel
'FileFormat:=xlNormal = 56
End Sub




Private Sub Workbook_Open()
Application.ScreenUpdating = False
Run "GetSerialNumberProtection"
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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