LockXLS On-line Help Library

Getting Started
Using LockXLS
How to ...
General Questions
Questions about LockXLS activation
Advanced Questions
LockXLS Runtime Menu
About LockXLS

Enable\Disable printing from VBA macro

To block printing operations for your workbook you should use the Additional Options | Disable printing in this workbook option. Also, you can dynamically enable\disable printing for a locked workbook from VBA code.

This VBA code shows how to disable printing:

' declare variable for LockXLS Runtime object
Dim oLockXLS As Object
' create LockXLS Runtime object
Set oLockXLS = CreateObject("LockXLSRuntime.Connect")
' disable printing
oLockXLS.EnablePrinting (ThisWorkbook, False)
' release LockXLS Runtime object
Set oLockXLS = Nothing

EnablePrinting( <workbook>, <IsEnable> ) method of the LockXLS Runtime object enables or disables printing. First parameter is locked workbook, second - boolean value True or False.

This call should be made only from this locked workbook. If it was made from other workbook\application, it will not make effect.

You can use similar macro to limit functionality of your workbook during trial period.

More To take more complex control on the printing (for example - limit count of pages) etc., you should use Workbook_BeforePrint event.

See Also

All methods of the LockXLS Runtime object