How does one capture a "Don't Save" or "Save" response to the Standard Suite "close" dialog?
try
close front document saving ask
on error
return
end try
returns "error number -10000" if the user selects "Cancel", so that case is handled.
However, subsequent code depends on whether "Don't Save" or "Save" was selected.
Thanks
UPDATE
Using regulus's answer and it's workaround strategy, I prefaced the code above with
tell application "Finder" to set _modDateAfterSaveDialog to
modification date of (info for file _filename)
where the _filename was assigned earlier from application-specific AS code.
Analogous code and a test followed the "try".
I really have no idea how to get it directly. I assume the command you are issuing is a specific application command, not a standard suite command because standard applescript doesn't have a "front document".
In any case, here's a work-around idea that might work. When a file is saved its modification date changes. So you need to know the file of the front document. Then you just check the modification date of the file before and after you issue this command. If it changed then you know the file was saved.
Good luck.
Related
do someone know if it's possible to execute a VBA code that send an email or windows notification when someone modifies, add a line for example or any modification. I want to use it for a file that help us to do regular check on the number of contracts delivered. So everytime someone types a new line, I can see it and put it on my own check file.
The Worksheet.Change event is what you want. In short, whenever one of a certain type of change is made to the worksheet, this code is run. You can read more about it on the documentation page here:https://learn.microsoft.com/en-us/office/vba/api/excel.worksheet.change
I am trying to do some validation on the file name before it's saved.
Here are my three file-saving scenarios:
File > Save
File > Save As > Browse > Save
File > Save As > Save
Additional Info:
As defined in the Workbook_BeforeSave event, the SaveAsUI parameter will indicate whether or not a dialog box is needed to save changes.
✓ In scenario 1, SaveAsUI=False, so I get the filename from ThisWorkbook.Name
✓ In scenario 2, SaveAsUI=True, so I force a dialog and get the file name with the GetSaveAsFilename method
✗ In scenario 3, SaveAsUI=True, but no intermediary dialog is ever actually required! The file gets immediately saved to that name entered in the input box.
...it's ridiculous that I'm obsessing over this because I can just override scenario 3 and force a dialog anyways, but I'm curious. Any ideas?
I'm writing this as an answer, because the comment field is too small for it.
I found the mentioned file reference in the registry:
HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Excel\User MRU\AD_2B763A186A5179F1E2C2819B76BF6FDEF3F399938D48925BE3381441F2190369\File MRU
You'll need a find, either to open the Recent file list, or to find a way to read such a registry entry. One way (but quite a complicated one), the Shell command, as you can see here (commandline command):
reg query "HKCU\Software\Microsoft\Office\16.0\Excel\User MRU" /s
Launching this command and parsing the results might help you.
I found what was missing in our missing vocabulary: Built-In Dialog Box
As explained here, there is no way to get the file name from this dialog until after the save has been made.
who in the pass tried to add an image to her signature, not too sure how she's done it but now she cant change her signature.
I used to be able to force it using the webmail signature function but thats not working anymore and anyway im way over due to fix this problem.
everytime she opens her preferences and when we want to modify her signature i have a popup windows that tells me :
field contains incorect value
“since you have chosen to append and HTML or image as a signature, you must include the filename that you wish to use.”
if i uncheck the "automaticaly add signature" option i dont get this error but as soon i re check it i get the window, even if theres nothing in the signature window, i've deleted everything in the text box same problem.
I reinstalled windows on another computer with our Ghost image, and on this clean install she has the same error so i guess its saved somewhere on my domino server
thanks a million.
Probably an error in her calendar profile. Use some tool to edit her calendar profile directly or just delete it.
I have a userform in Excel in which the user enters information and then hits an "add stock" button. Upon pressing this button, the information is entered into a spreadsheet and then the spreadsheet is saved with "ActiveWorkbook.Save".
The problem is that the work computers are old and Excel has a tendency to crash. When the spreadsheet is autorecovered, the add stock function no longer works, it crashes with a code 75 error. It seems that ActiveWorkbook.Save doesn't work in this case, until the user manually hits CTRL-S. The boss is adamant that our users are not computer savvy enough to manage this so I need to somehow check if Excel has crashed and if so automatically save the file before they start using it.
How would I check if we're in an autorecovery state, and then save it (without ActiveWorkbook.Save) so that the user can continue using the form without issues? Many thanks.
I can't find a direct way to check this, but here are a couple of kludgy options. It seems that if there are two states a workbook that an Autorecovered workbook can be in: Last saved by user or Autosaved. The caption reflects which state it's in. This function will check for the existence of that phrase in the caption.
Public Function IsInAutoRecoverMode(wb As Workbook)
Dim wn As Window
Set wn = wb.Windows(1)
IsInAutoRecoverMode = _
wn.Caption Like "*[Autosaved]?" Or _
wn.Caption Like "*[Last saved by user]?"
End Function
I'm not sure if there are more states that just this and this will certainly fail in non-English environments, so use with care.
When Last saved by user, the Workbook.Path property is where the file is stored. When Autosaved, the Workbook.Path property is equal to Application.AutoRecover.Path. Well, they're equal on my machine. That may just be a coincidence, but I doubt it.
Because the Last saved by user Path isn't distinctive, you can't use it to determine if you're in Autorecover mode. But if the user open the Autosaved workbook, you probably don't want to just Save, but rather Save As in the right location. You might need to use both these techniques to get the solution you want.
Make sure you tell your boss that these work-arounds because you're so industrious and inventive, but they are not documented and might fail at any time. At least, I wouldn't use them without understanding that they're based on some guesses. Let us know what you end up with.
I'm writing an application that processes PowerPoint presentations and I'm looking into ways of detecting whether or not a PowerPoint presentation has a password if it does then stop processing it.
It seems to me that there is no way to check if the presentation is password-protected. You have to open the document first to make properties accessible. You have to provide the password when you are opening the document.
There is a Password Property you can check.
I've found a workaround on Expert Exchange:
The problem is the following: Visual
Basic is a single threaded
application, this means that you cant
put a certain procedure on hold and
proceed with another (in the same
application). When powerpoint has an
"on open"-password set, the
CreateObject procedure inside your
application is put on hold untill
powerpoint releases it, this is when
the user types in a password. There is
no way around this that I know off,
but you can make a workaround:
Make 2 applications, 1 application is
the application you already have, the
second one is a "powerpoint unlocker".
You run the second program just before
you open the protected powerpoint
presentation in application 1. You can
do that with the shell command. The
"powerpoint unlocker" can be as
advanced as you want it to be, you can
for example provide command line
parameters to specify which
presentation must be unlocked with
what password. Then you use the
findwindow api to get the window
handle of the locked presentation.
Once you have that, you use the
sendmessage api to input the password.
After this the "powerpoint unlocker"
unloads and the first application can
resume with its excution.
I hope this helps!
Osmodean
Consider looking at this -
http://blogs.msdn.com/b/openspecification/archive/2009/07/17/overview-of-protected-office-open-xml-documents.aspx
For a PPTX document, you can examine the first 8 bytes to look at the header (should be [d0cf 11e0 a1b1 1ae1] for an encrypted file), and know if it is an encrypted PPTX or not.
However, for files created with Office 2003 (default extension .ppt), the header is the same (MS-CFB header). So, if somebody creates an office 2003 document and then renames it to a PPTX, your code will consider it as an encrypted document (whereas, it wouldn't necessarily be one).
If you are working with documents already opened in Powerpoint, you can use the SaveCopyAs function to first save the document to disk in the pptx format (use the default option in the second parameter), and then examine the header to check if it's an encrypted file.
Consider looking at this -
https://msdn.microsoft.com/ko-kr/library/dd948895(v=office.12).aspx
For a PPT(office 2003) document, you can examine the unsigned integer(0xF3D1C4DF bits) to identify whether the file is encrypted.