Purpose: loading/Saving workbooks through VBA SetOption helper
If you enabled the “Do not allow loading/saving other workbooks” option (see Do not allow loading/saving other workbooks paragraph) and still need to do it through VBA, do this:
-Enable the following Advanced option:
-Then, use the following VBA code snippet:
Dim wkb As WorkbookOn Error Resume Next
' Adding New Workbook
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:="2", Value:="0"
XLSPadlock.SetOption Option:="1", Value:="1"
wkb.SaveAs "D:\My Documents\WorkbookName.xlsx"
XLSPadlock.SetOption Option:="2", Value:="1"
XLSPadlock.SetOption Option:="1", Value:="0"
You can see the following line:
XLSPadlock.SetOption Option:="2", Value:="0"
This line tells XLS Padlock to allow loading/saving workbooks as usual. Value should be either 1 (True) or 0 (False).
The second line
XLSPadlock.SetOption Option:="1", Value:="1"
tells XLS Padlock to disable the prompt to save encrypted workbooks.
After having saved the workbook, be sure to call:
XLSPadlock.SetOption Option:="2", Value:="1"
XLSPadlock.SetOption Option:="1", Value:="0"
It will restore the default behavior.