Hi all,
I have written a script for MultiAd Creator that will read the modification date of an open already saved current document and when the user tries to save, it will notify the user if the doc is more than 5 days old, giving them the option to cancel the save or continue with it. So far I have got it to work on preexisting files, but when I create a new doc and try to save I run into an error and cannot save it. I tried rewriting the script and ran into more problems. Could someone please help. I have attached both versions to show what I have done so far.
This is the one that works for preexisting files but won’t allow me to save new files:
using terms from application "MultiAd Creator Pro"
on saving theFile
set DocAlias to the folder of front document
set theFile to the name of front document
set DocName to DocAlias & theFile as string
set DocName to DocName as alias
set DocInfo to get info for DocName
set ModifDate to modification date of DocInfo
set isItOld to (current date) - (5 * days)
if ModifDate ≤ isItOld then
tell application "MultiAd Creator Pro"
set saveOrNot to display dialog "Ad is a repeat, are you sure you want to save over it?" buttons {"Don't Save", "Save"} default button "Don't Save"
if button returned of saveOrNot is "Save" then
save front document
else if button returned of saveOrNot is "Don't Save" then
save as front document
end if
end tell
end if
end saving
end using terms from
This is my second shot that doesn’t work at all:
set theDoc to ""
using terms from application "MultiAd Creator Pro"
on opened theFile
set theFolder to the folder of front document
set theName to the name of front document
set theDoc to theFolder & theName
end opened
end using terms from
using terms from application "MultiAd Creator Pro"
on saving theFile
if theDoc = "" then
--do nothing
else
tell application "Finder"
set DocInfo to get info for file theDoc
set ModifDate to the modification date of DocInfo
set DateMinus5 to (current date) - (5 * days)
end tell
if ModifDate ≤ DateMinus5 then
set saveOrNot to display dialog "Ad is a repeat, are you sure you want to save over it?" buttons {"Don't Save", "Save"} default button "Don't Save" with icon stop
if button returned of saveOrNot is "Save" then
save front document
else if button returned of saveOrNot is "Don't Save" then
save as front document
end if
end if
end if
end saving
end using terms from