Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
bshbsh
403 Views, 3 Replies

Differentiate Save from Save As... in AppEvents_OnSaveDocument?

Hi all,

I'm having a macro which updates our database when a file is saved. This uses the AppEvents_OnSaveDocument event (amongst others but this is the problematic one).

The (rare, but annoying) problem is, when someone imports like a STEP file or something, and instead of saving it, he saves it with "save as" under a different name.

However, the event triggered kAfter still thinks the document in question is the imported and unsaved one, it even provides (non-existent, since never saved) filenames and such things - and this is where the macro fails since the file doesn't even exists.

What would be the best and fastest way to circumvent this? Right now I'm checking if the filesavecounter is not 0 before calling the update routine.

I see in the event Context that there are two filenames: one is the imported (unsaved) one and the other is the "save as" name. Could this be reliably used to detect save as?

I just don't wanna check for FileExists every time, that is too slow.

 

Thanks for any ideas.