Allow saving non encrypted workbooks

 

 

Purpose: allow saving non encrypted workbooks

As a VBA programmer, if you use the instruction newworkbook.saveas, XLS Padlock saves an encrypted workbook file. If you want to save a normal workbook, you can use the following VBA code snippet:

Dim wkb As Workbook

' Adding New WorkbookOn Error Resume Next

Set wkb = Workbooks.Add

' Do what you need…

'Saving the Workbook

Dim XLSPadlock As Object

Set XLSPadlock = Application.COMAddIns("GXLS.GXLSPLock").Object

XLSPadlock.SetOption Option:="1", Value:="1"

 

wkb.SaveAs "C:\My Documents\WorkbookName.xls"

XLSPadlock.SetOption Option:="1", Value:="0"

 

You can see the following line:

XLSPadlock.SetOption Option:="1", Value:="1"

 

This line tells XLS Padlock to allow a normal workbook to be saved. Value should be either 1 (True) or 0 (False).

After having saved the workbook, be sure to call:

XLSPadlock.SetOption Option:="1", Value:="0"

 

It will restore the default save behavior.

 

XLS Padlock will prevent saving normal workbooks if the security option “Do not allow loading/saving other workbooks” is enabled. To solve this problem, see Loading/Saving workbooks through VBA SetOption helper.

 

 

 

 

 


Copyright © 2023 G.D.G. Software