LockXLS On-line Help Library

Welcome
Getting Started
Using LockXLS
How to ...
General Questions
Questions about LockXLS activation
Advanced Questions
LockXLS Runtime Menu
Use LockXLS Menu commands in your custom menu
ShowHide LockXLS Runtime menu in Excel
Add About Box to your workbook
Samples
About LockXLS
Purchase
Contact
Use LockXLS Menu commands in your custom menu

Use LockXLS Menu commands in your custom menu.

You can use LockXLS commands in your custom menu, or call them from your VBA code.

LockXLS allows to call these commands through it's COM object model. This sample code shows you, how to call "Save Modified Data" command from custom menu item.

Public Sub OnMyButtonClick()
' declare variable for LockXLS Runtime object
Dim oLockXLS As Object
' create LockXLS Runtime object
Set oLockXLS = CreateObject("LockXLSRuntime.Connect")
' call command
oLockXLS.RunCommand ("LockXLS_Export")
' release LockXLS Runtime object
Set oLockXLS = Nothing
End Sub

RunCommand( <Command ID>, (optional)<Workbook>) method calls handler for each LockXLS menu command. Possible values for Command ID parameter:

  • LockXLS_EnterAC enter Activation Code, same as "Register" button in LockXLS menu
  • LockXLS_EnterSN enter Serial Number (activate workbook protected with Serial Number option)
  • LockXLS_RemoveAC remove activation information, same as "Unregister" button in LockXLS menu
  • LockXLS_Export save modified data
  • LockXLS_Import load external data
  • LockXLS_SaveAll save all data
  • LockXLS_SaveAllNoUI save all data, without asking for cell color
  • LockXLS_Menu_Enable enable LockXLS menu commands
  • LockXLS_Menu_Disable disable LockXLS menu commands

Second parameter Workbook is used only when you are using this code inside of addin. By default LockXLS Runtime uses workbook which is currently active to add/remove activation code and perform operations with data.

Addin is never became active, so menu and tab on the ribbon will never became visible. For addin you should install your own toolbar (tab on the ribbon) and create VBA code for Enter Activation Code \ Remove Activation menu items. In this code you should use this statement:

...
oLockXLS.RunCommand ("LockXLS_Menu_Enable", ThisWorkbook )
...

Second parameter passes workbook object which represents your addin to the LockXLS Runtime.

Please, note, LockXLS Runtime will collect modified data only if LockXLS menu is enabled. So, if you are using Save Modified Data command from your VBA Code, or from your menu, you should call the following procedure, to enable this feature.

Public Sub EnableLockXLSMenu()
' declare variable for LockXLS Runtime object
Dim oLockXLS As Object
' create LockXLS Runtime object
Set oLockXLS = CreateObject("LockXLSRuntime.Connect")
' call command
oLockXLS.RunCommand ("LockXLS_Menu_Enable")
' release LockXLS Runtime object
Set oLockXLS = Nothing
End Sub

If LockXLS was not enabled LockXLS Runtime will start collecting data only after this call. To stop collecting data you should use LockXLS_Menu_Enable command.

See Also

All methods of the LockXLS Runtime object