Saving with vba code

when you are saying “encrypted workbook” you mean the “compile to EXE” functions ?

if so, I bought the XLS padlock because of this, and without those functions my applications is not protected.

No, encrypted workbook means the XLSC file that is saved by end users when they want to keep changes.
From what I saw on your first post, you want to load/make your own saves, so you don’t need the SaveSecureWorkbookToFile VBA code. You need to tell XLS Padlock that you want to save normal workbooks yourself with the Workbook.SaveAs function. And for that, you have to set an option through VBA code: please refer to this paragraph in the user guide.

9.6 Allow saving non encrypted workbooks

Ok now I’m a little bit confuse.

You are talking about “SaveAs” function and form what I know, I do not need “SaveAs” all I need is just “Save”.

right now I tested that code (9.6 in the user guide) and it open the “save as” dialog box (that I do not need).

can you send me a simple workbook that when I click a butten this workbook (the active workbook, the one with the code), will be saved, like you used the THISWORKBOOK.SAVE function.

Then just replace the SaveAs with more parameters to disable the dialog box.

ActiveWorkbook.SaveAs Filename:=vFile, FileFormat:= …

it’s not working. please publish here a code or send me a workbook with an example.

the workbook will be tested in my desktop.

TNX

It’s just an example. Please search for ActiveWorkbook.SaveAs and you’ll find VBA code snippets.

I know how to use the SAVEAS function but I don’t know how to use it with the XLS Padlock especially with the 9.6 section that it still not yet clear for me, why is this section what I need.

Im still not sure that you understand me right and Im not sure that I understand you right, this is the reason why I need you to publish a simple code.

Try this one:

Sub SaveItNowTest()
'On Error Resume Next
Set XLSPadlock = Application.COMAddIns("GXLSForm.GXLSFormula").Object
PathToFile = XLSPadlock.PLEvalVar("EXEPath") & "myPREVIOUSworkbook.xlsm"
Set XLSPadlock = Application.COMAddIns("GXLS.GXLSPLock").Object
XLSPadlock.SetOption Option:="1", Value:="1"
 
ActiveWorkbook.SaveAs PathToFile
 
XLSPadlock.SetOption Option:="1", Value:="0"

End Sub

OK, I’m sorry but I see that you didn’t undersant me.

Like I said before, I don’t want to SAVEAS (new file), all I want to do is just save the EXE file “as is”.
not to SAVEAS the EXE file to a new EXE file.
not to SAVEAS a new XLSM/XLSX/XLS workbook
not to SAVE with an option to go back in the EXE file to a previous version
not to SAVE with any kind of dialog box

imagine, that you have a workbook that in the end of each sub/function you ends it with the line of code : THISWORKBOOK.SAVE. - this is what I have and this is what I need, is that simple :smile:

is it possible ?

Thanks a lot !!!

What you exactly want doesn’t exist “as is” so you’ll have to deal with that solution:

  • use VBA to save your workbook as secure workbook (and without dialog) with SaveSecureWorkbookToFile as seen above.
  • create a link to the EXE file that passes the secure workbook file as command-line argument.
    The application EXE file accepts some command-line switches:
    “MYAPP.EXE [path to the XLSC file]” will directly load the XLSC file without prompting the user which save he wants to load.

OK lets try it… can you publish a code that’s do it ? because I don’t know how to do it.

It’s the same code as above and the first workbook sample uploaded in this topic.

I don’t know how to combine the two codes together, please show me how to do it, because I finally what to start using the xls padlock

You don’t have to combine two codes. There is only the code to save the encrypted workbook. To load it back, you run the EXE with command-line argument. Then no dialog box will be displayed and the encrypted workbook previously saved will load.

but how do i call the EXE ?

?

I tried with the Workbook_Open event now, and it’s not working:

Private Sub Workbook_Open()
MYAPP.EXE
End Sub

Don’t use VBA. You can create a shortcut (.LNK) or use command-line CMD or use a Batch file.

I think I dont know how to create a .LNK and command-line CMD or use a batch file.

and before I learn how to do it, is it possible to distrbute it to my end-user with my exe file?

Sure, you can distribute a batch file with your EXE.
Or you can wait for the next release of XLS Padlock (in January) in which we’ll offer the way to load/save the workbook without any prompt, as you requested.

Or you can wait for the next release of XLS Padlock (in January) in which we’ll offer the way to load/save the workbook without any prompt, as you requested.

This is a great news, I will wait for the next release in January. try to do this feature without any extra file except the EXE file and it will be excellent. no need to search for XLSC file’s, no need to worry maybe my end user will delete XLSC and things like that, all project in one EXE file.

Hello there,

What’s new ?