$0+

Excel Add-In License Validation for Gumroad (Free for limited time)

I want this!

Excel Add-In License Validation for Gumroad (Free for limited time)

$0+

When creating an Excel spreadsheet or Add-in for distribution, one concern is licensing the add-in to control distribution of it. This code can help you license you Excel add-ins for sale and distribution.
This VBA code is designed for an Excel add-in that manages license activation for a product using Gumroad as a licensing platform. Here's a step-by-step explanation:

  1. Global Variables:
    • IsActivated: Boolean variable to store activation status.
    • ProductID: String variable to store the product ID.
    • machineID: String variable to store a machine-specific ID.
    • Json: Object variable to declare a JSON object.
  2. Constants:
    • YOUR_COMPANY_NAME: Your company name for storage in the Windows Registry.
    • LICENSE_STORAGE_LOCATION: Storage location in the Windows Registry for license-related information.
    • GUMROAD_PRODUCT_ID: Constant string representing the Gumroad product ID.
  3. SetupAddIn Subroutine:
    • Sets the ProductID constant in the code.
    • Saves the entered product ID and generated machine-specific ID securely in the Windows Registry.
  4. CheckLicenseKeyActivation Function:
    • Checks if a license key is already present in the registry.
    • If not, prompts the user to enter a license key, validates it, and associates it with the current machine.
    • If a license key is found, checks its validity and association with the current machine.
  5. IsValidLicenseKey Function:
    • Sends a request to the Gumroad API to verify the license key's validity.
  6. PostHTTPResponse Function:
    • Sends a POST request to a specified URL with provided POST data and returns the HTTP response.
  7. SaveActivationStatus Subroutine:
    • Saves the activation status to the same storage location in the Windows Registry.
  8. LoadActivationStatus Function:
    • Loads the activation status from the same storage location in the Windows Registry.
  9. SaveToConfigFile Function:
    • Saves key-value pairs to the Windows Registry.
  10. LoadFromConfigFile Function:
    • Loads a value associated with a specific key from the Windows Registry.
  11. GetMachineID Function:
    • Generates a machine-specific ID (for simplicity, it uses the Windows username).
  12. ValidateMachineID Function:
    • Validates that the machine ID in the license matches the current machine.
  13. EncryptText and DecryptText Functions:
    • Placeholder implementations for text encryption and decryption.
  14. BytesToString Function:
    • Converts an array of bytes to a string.

Implementation Steps:

  • Modify the YOUR_COMPANY_NAME, LICENSE_STORAGE_LOCATION, and GUMROAD_PRODUCT_ID constants according to your requirements.
  • Integrate this code into your Excel add-in project by copying and pasting it into a module, and renaming the module appropriately (ie Check_License_Key_Activation).
  • Use the CheckLicenseKeyActivation function to handle the license activation process in your add-in. (Meaning put this at the begining of your module to call the Check_License_Key_Activation module to do the check)
  • ' Check the activation before proceeding If Not Check_License_Key_Activation.CheckLicenseKeyActivation() Then MsgBox "Invalid or missing license key. Please activate the license first.", vbExclamation Exit Sub ' or you can choose another action, like showing a form or disabling functionality End If


Note: Ensure you have the necessary permissions to modify the Windows Registry, and be cautious while working with license-related functionalities. Additionally, replace placeholder logic with robust encryption mechanisms for actual security requirements.

Note: Keep in the provided licensing code can be adapted to work with other licensing platforms or systems. The key areas to modify would be the functions related to license key validation, such as IsValidLicenseKey and the URL used for license verification in the PostHTTPResponse function.

Note: This code uses JSON parsing as such you will need to integrate into your project, here are some simple steps.

  1. Download the VBA-JSON Library:
    • You can download the VBA-JSON library from its GitHub repository: VBA-JSON GitHub Repository.
    • On the GitHub page, click on the green "Code" button and select "Download ZIP" to download the entire repository.
  2. Extract the ZIP File:
    • Extract the contents of the downloaded ZIP file to a location on your computer.
  3. Import the JSON.bas Module:
    • Open your Excel workbook.
    • Press Alt + F11 to open the Visual Basic for Applications (VBA) editor.
    • In the VBA editor, right-click on the project where you want to add JSON parsing functionality (e.g., the workbook or a new module).
    • Choose "Import File" and select the JSON.bas file from the extracted VBA-JSON library.
  4. Reference the Library:
    • In the VBA editor, go to "Tools" > "References..."
    • In the "References" dialog, find and check "Microsoft Scripting Runtime" (for dictionaries) and "Microsoft ActiveX Data Objects x.x Library" (for ADODB.Stream).
    • Click "OK" to apply the references.


Good luck with your Excel VBA projects.

$
I want this!
4 downloads
Size
17.3 KB
Length
7 pages
Copy product URL