Directly saving a workbook to an unsecured version

I am working on converting a macro that deletes a bunch of content and removes the VBA components of the software and then saves the files to .xlsx.

In the locked version of the software the process I have mostly working is:

  1. Save the secured file
  2. Delete the unwanted content in the secured file
  3. Open a new workbook (using “workbooks.add”)
  4. Copy the remaining content of the secured file to a new workbook
  5. Save the new workbook as an unsecured file
  6. Close the secured file (without saving)

What I would prefer to do is:

  1. Save the secured file
  2. Delete the unwanted content in the secured file
  3. Save the secured file directly as an unsecured file
  4. Close the secured file (without saving)
  5. Re-open the original secured file

Is this possible? I can’t seem to get it working. The two steps that I am not sure about are directly saving to an unsecured file (rather than copying the content to a new workbook first) and opening a save file through vba.

Also, is possible to get the path to the save file folder (rather than the full path of the save file)? If not, I can figure out a way to extract this, but I would rather avoid the additional steps if possible.

Thanks for the help

It is possible to save unencrypted workbooks with VBA (if you did not configure XLS Padlock to forbid it).

You can get the path to the EXE folder, is it what you wish?

I have forbidden saving to an unencrypted workbook but am temporarily turning that off through the set option vba commands mentioned in section 11 of the user manual. From what I can tell, the code in section 11 let’s you start a new blank workbook (workbooks.add) and save it, but what I am looking for is the vba to directly save the current file as an unencrypted file.

The next thing I am looking for is how to get the path to the folder that the save file is located in (.xlsc), not the exe file.

The third thing I am looking for is a way to open a secured save file through vba.

I am not sure if any of these can be done.

Thanks

This is not possible. Only the EXE itself can open a secure save file.

Use the XLS Padlock VBA API to retrieve the full name to the save file that is loaded, then use VBA code to get the path to the folder only.

Here is what I have done to save an unprotected version of the file with some of the information taken out:

Application.DisplayAlerts = False
Dim XLSPadlock As Object
Set XLSPadlock = Application.COMAddIns(“GXLS.GXLSPLock”).Object
XLSPadlock.SetOption Option:=“2”, Value:=“0”
XLSPadlock.SetOption Option:=“1”, Value:=“1”
myfile = GetSecureWorkbookFilename
SaveSecureWorkbookToFile (myfile)
filePath = Replace(GetSecureWorkbookFilename, “.xlsc”, “”)
ThisWorkbook.SaveCopyAs filePath & “.xls”
Set wkb = Workbooks.Open(filePath & “.xls”)
'MAKE MODIFICATIONS TO THE .WKB FILE
wkb.SaveAs filePath & “.xlsx”, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
wkb.Close
Kill filePath & “.xls”
XLSPadlock.SetOption Option:=“2”, Value:=“1”
XLSPadlock.SetOption Option:=“1”, Value:=“0”
Application.ScreenUpdating = True

It is working, but I get a saveas prompt for the .xlsc file at the wkb.SaveAs step. I am trying to figure out how to get around this prompt, but can not spend more time on this for now. If you know how I could get this all to run without any prompts please let me know.

Ok I got it working with some minor changes

Application.DisplayAlerts = False
myfile = GetSecureWorkbookFilename
SaveSecureWorkbookToFile (myfile)
filePath = Replace(GetSecureWorkbookFilename, “.xlsc”, “”)
Dim XLSPadlock As Object
Set XLSPadlock = Application.COMAddIns(“GXLS.GXLSPLock”).Object
XLSPadlock.SetOption Option:=“2”, Value:=“0”
XLSPadlock.SetOption Option:=“1”, Value:=“1”
ThisWorkbook.SaveCopyAs filePath & “.xls”
Set wkb = Workbooks.Open(filePath & “.xls”)
XLSPadlock.SetOption Option:=“2”, Value:=“1”
XLSPadlock.SetOption Option:=“1”, Value:=“0”
'MAKE MODIFICATIONS TO THE .WKB FILE
XLSPadlock.SetOption Option:=“2”, Value:=“0”
XLSPadlock.SetOption Option:=“1”, Value:=“1”
wkb.SaveAs filePath & “.xlsx”, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
wkb.Close
Kill filePath & “.xls”
XLSPadlock.SetOption Option:=“2”, Value:=“1”
XLSPadlock.SetOption Option:=“1”, Value:=“0”
Application.DisplayAlerts = true