Skip to content

Instantly share code, notes, and snippets.

@ScottDeLuzio
Created February 18, 2016 22:35
Show Gist options
  • Save ScottDeLuzio/29be922cc11649afc7ea to your computer and use it in GitHub Desktop.
Save ScottDeLuzio/29be922cc11649afc7ea to your computer and use it in GitHub Desktop.
Software Licensing for Excel Add-In UserForm Deactivate
Private Sub LicenseKeyDeactivate_Click()
If license.Value = "" Then
MsgBox "Please enter a license key.", vbExclamation, "Input Data"
Exit Sub
Else
Application.ScreenUpdating = False
With ThisWorkbook.Worksheets("Sheet1").Range("A1")
.Cells(1, 1).Value = license.Value
End With
ThisWorkbook.Save
httpRequestDeactivate
Unload Me
Application.ScreenUpdating = True
httpRequestCheck
With ThisWorkbook.Worksheets("Sheet1").Range("A1")
If .Cells(4, 1).Value <> 0 Then
MsgBox "Your license key has been deactivated. If you no longer intend to use this add-in on this computer please remove it from your list of Add-Ins to avoid license activation prompts at startup."
'You should call a function to hide or disable your add-in here otherwise it can still be used until the user restarts Excel.
Else
MsgBox "Your license key may not have been deactivated. Please close and restart Excel to re-check your license."
'You should call a function to hide or disable your add-in here otherwise it can still be used until the user restarts Excel.
End If
End With
End If
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment