Purpose: How to Start Deactivation of the Workbook Application With VBA

The following VBA code lets users start the deactivation process on their computer.

Public Sub StartDeactivation() 
Dim XLSPadlock As Object 
On Error GoTo Err 
Set XLSPadlock = Application.COMAddIns("GXLSForm.GXLSFormula").Object 
XLSPadlock.PLDeactivate 
Err: 
End Sub

 

You can then invoke the sub thanks to a macro assigned to a button for instance:

 

Sub AskForDeactivation()
    Dim response As Integer
    
    ' Ask the user if they really want to deactivate the application
    response = MsgBox("Do you really want to deactivate the application?", vbQuestion + vbYesNo, "Confirm Deactivation")
    
    ' Check the user's response
    If response = vbNo Then
        ' If the user selects "No," exit the procedure
        Exit Sub
    Else
        ' If the user selects "Yes," you can call the deactivation function here
         Call StartDeactivation
         Application.Quit
    End If
End Sub 
 

 

In our workbook demo app, we added a simple Deactivate button.

 

ℹ️ Please note the "Application.Quit" command in the code above to make sure that Excel is closed before we start deactivating the application.