Save Dialog Box


#1

How can I open the secure save dialog box via a macro to bypass clicking file and then save?

I need the exact same functionality as if a user was clicking file then save… only clicking a command button instead to open the secure save dialog box.

Is this possible?


#2

Invoke ThisWorkbook.Save VBA method without UI prompt.


#3

Hi Support,

If you invoke ThisWorkbook.Save VBA method without UI prompt to save the XLSC file, once you open the EXE and choose “Last Save”, will that open the file saved through ThisWorkbook.Save VBA?

Thanks,


#4

Yes, because ThisWorkbook.Save will be caught by XLS Padlock and trigger the usual Save Secure File dialog box asking the user to choose where to save the XLSC file. Then, the file is remembered in the history and users will be able to load it back.


#5

I have a similar need as barcop101: I want to open the secure save dialog box via a macro to encourage my customer to save his xlsc.

So I tried with ThisWorkbook.Save .
Used in sub A this works fine. Put in an other sub B, this does not work.

Sub B is the Private Sub Workbook_BeforePrint (cancel As Boolean) automatically enabled before a printing process.

If as an alternative in Sub B instead of invoking ThisWorkbook.Save I just call Sub A (containing ThisWorkbook.Save) this does not work either.

I want to make sure, that my customers save their xlsc-files BEFORE they print them and before they create a pdf thereof. The secure save dialog box should therefore open before such an event and the file should be saved before it is printed. How to achieve that?


#6

Could you first check that your events are correctly fired (e.g. by putting a msgbox in Workbook_BeforePrint)?


#7

Yes, I confirm that Workbook_BeforePrint fires correctly.


#8

Looks like Excel doesn’t allow saving once before print is fired. So, there is no possibility for us.


#9

Thank you for investigating.

Yes, I verified that (the uncoded) Excel allows saving once before print is fired using Private Sub Workbook_BeforePrint. However not with the command ThisWorkbook.Save (in the uncoded Excel this command does not initiate saveas and no dialog). The command (or set of commands) needed to saveas with dialog in the uncoded Excel are different. They work in any sub, they are integrated in. However all the different commands explored do not work correctly within the coded Excel.

It is the padlock-coded Excel that does not execute the command ThisWorkbook.Save (saving with xlsc-save-dialog-box) correctly when this command is integrated in the Private Sub Workbook_BeforePrint (cancel As Boolean) or in any other sub called within the Private Sub Workbook_BeforePrint.

So the problem only arises with the padlock-coded Excel. Why?

For the padlock-coded Excel to initiate saving with the xlsc-save-dialog-box the command ThisWorkbook.Save was recommended. It seems strange to me, that with this command a different action is initiated in the coded Excel (saveas with dialog) than in the uncoded Excel (save without dialog). Why?

Are there alternative commands or set of commands for the coded Excel to initiate saving with xlsc-save-dialog-box?

How can I solve my problem?


#10

Could you try this?
image


#11

Unfortunately no success:

I tried both the suggested 11.3 method as well as the 11.4 method (Suggest a filename for the save dialog box) from the Padlock Manual.
Both of them I tried as a call from the Private Sub Workbook_BeforePrint (cancel As Boolean) as well as a call from an ordinary sub.
All of them run without error messages. However in none of the 4 cases the save dialog box appeared in the padlock-coded excel!

Whereas the save dialog box appears in the coded excel with the ThisWorkbook.Save call in an ordinary sub (remind my problem: does not appear when ThisWorkbook.Save is part of the Private Sub Workbook_BeforePrint (cancel As Boolean))

I do not understand anyway, what the 11.4 method is aiming at if it is not opening the save dialog box in any case.


#12

Because we first need to know whether the workbook file is correctly saved as a secure file or not in the Private Sub Workbook_BeforePrint.
Other questions: do you use Application.EnableEvents? And Workbook_AfterSave?
And which Excel version are you using?


#13

Thank you.

Because you first need to know… Either of the two situations may occur.

Yes I use Applications.EnableEvents. It is set on false just before the command intended for saving with xlsc-save-dialog-box. Reason: to inhibit firing of the Public Sub Workbook_BeforeSave.

No I do not use Workbook_After Save.

Excel version: Office 365 Excel Version 1902
MSO (16.0.11328.20140) 64-Bit


#14

Applications.EnableEvents = False is probably the culprit because XLS Padlock uses events to trigger the “Save As” dialog box.


#15

True indeed!
Thank you, problem solved!


#16

Hi Support,

You said in one of the posts above:

Invoke ThisWorkbook.Save VBA method without UI prompt.

But the macro below always prompt the user with the “Save local workbook” dialog box.
Is there a way to not prompt the user and just save the file?

Sub Save()
ThisWorkbook.Save
End Sub

It is interesting that if I run this macro in a normal Excel file, it doesn’t not prompt with the dialog box, but it does when I run it in a EXE file.

Thanks,


#17

Hi Support,
Can you please advise on my previous post?
Thanks,


#18

You could use the VBA sample that is in the user guide:


#19

Hi Support,

I was using the macro you just suggested but the problem with it is that the EXE doesn’t remember the history, so the user cannot choose “Last Save” and needs to browse to open the file, which defeats the whole purpose of having a macro for easy saving if it makes more difficult to open.

Do you have any other suggestion to run the ThisWorkbook.Save macro without “Save local workbook” dialog box, saving the XLSC file without prompting the user?

Cheers


#20

That’s strange because the save file made the macro we suggested is indeed stored into the history. So, it should be remembered when you click Last Save. Could you double-check?