Saving with vba code

Hallo,
I want also save a secured sheet without a message box with as san message

Public Function SaveSecureWorkbookToFile(Filename As String)
On Error GoTo Err
Set XLSPadlock = Application.COMAddIns(“GXLS.gxlsPlock”).Object
SaveSecureWorkbookToFile = XLSPadlock.SaveWorkbook(Filename)
Exit Function
Err:
MsgBox "Function SaveSecureWorkbookToFile NOT ok"
SaveSecureWorkbookToFile = ""
End Function

Sub TestSave()
SaveSecureWorkbookToFile (“R:\my save.xlsc”)
End Sub

When is the error handling is disabled. The Runtime error “9” disappears, at
Set XLSPadlock = Application.COMAddIns(“GXLS.gxlsPlock”).Object

How solve it.

The add-in you mentioned is a built-in one and is only available at runtime (when compiled in the EXE). At design time, in
Excel, an error will be triggered. That’s why you have to use On Error GoTo Err

We will release a new version of XLS Padlock this week with that option (save without prompt and reload changes next time automatically).

Can’t wait for this release, I bought the XLS PADLOCK 3 month ago and I didn’t use it even once.

Good for you that you are attentive to the needs of your customers.

Thank you

Hi. I´ve been recently trying to use your new save function “Save changes automatically and load them without prompt next time” on my compiled .exe VBA project. However without success. On userform_terminate I would like to automatically save the file so all the changes within workbook will be available next time I run my .exe file.

Existing code…
ThisWorkbook.Close Savechanges:=True
Application.Quit

…apparently doesn´t seem to work. Any guidance would be greatly appreciated.
Thanks

We tested the code you posted and it works. Changes are saved, but the application doesn’t quit (it doesn’t quit even in normal Excel though).

Still doesn´t work for me. I made a new simple vba to check whether there is a issue with my code however it seems to be doing exactly the same. The VBA consists of userform with one textbox. Anything what I write to textboxt gets written in A1 cell. Once I cancel the userform the workbook gets saved. If I do that in excel anytime I open the workbook again the last input remains in the cell as it should be. However if I do it with compiled .exe file the save function doesn´t seem to be working. Code below.

Private Sub Workbook_Open()
UserForm1.Show
End Sub

Private Sub TextBox1_Change()
Sheets(“List1”).Range(“A1”) = TextBox1
End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
ThisWorkbook.Close Savechanges:=True
End Sub

Thanks for your help

This code works:

Private Sub CommandButton1_Click()
 Unload Me
End Sub

Private Sub UserForm_Terminate()
ThisWorkbook.Close Savechanges:=True
Application.Quit
End Sub

Nope, still doesn´t work. Again, it works in excel however once I compiled it to .exe file the value doesn´t get saved. My updated code:

Private Sub Workbook_Open()
UserForm1.Show
End Sub

Private Sub CommandButton1_Click()
Unload Me
End Sub

Private Sub TextBox1_Change()
Sheets(“List1”).Range(“A1”) = TextBox1
End Sub

Private Sub Userform_terminate()
ThisWorkbook.Close Savechanges:=True
Application.Quit
End Sub

What about replacing

ThisWorkbook.Close Savechanges:=True

By

ThisWorkbook.Save
ThisWorkbook.Close

Still the same-works in excel but not after compilation with your app. Do you test the code you recommend? Does the code work for you?

Yes, we test code and it works.

See steps:

When pressing button, prompted for save filename

Next time starting EXE:

Value was saved:

Finally the problem was that I had only second option ticked. The first option has to be ticked as well. Sorry for that. Thanks for your support.

Great, thanks for the follow-up. In XLS Padlock 2.2.1, the second option is now disabled if the first one is not checked.

Hi, JanJ
I saw your string of messages with gdg and I’d like to know if you simply inserted the function and made the variable Filename includes the whole name of the file with the extension .xlsc?

I greatly appreciate your feedback because I am having VBA error saying the variable XLSPadlock was not declared.

Thanks a million.

Roberto

Public Function SaveSecureWorkbookToFile(FileName As String)
On Error GoTo Err

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

Exit Function
Err:
SaveSecureWorkbookToFile = ""
End Function

Hi Skoriq,
Didi you solve your issue? because I am having the same and I’d like to know your process worked out.
Thanks in advance. Have a great day.
Roberto

Hi nd09,
Did you sole the issue with saving the file into the .xlsc?
Have you received a VBA error saying “Variable not defined” and pointing into the “XLSPadlock” below?

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

Thanks,
Roberto

Hi Roberto,

in my case simple

ThisWorkbook.save

worked out well in the end. Let me know if this helps to solve your issue,

Cheers
Jan

Thank you Jan,
Yes, it helped a lot.
Cheers,
Roberto