If I disable the instructions dedicated to MultiAd, the script displays the dialog “want to save .”
So my understanding is that the problem is the syntax of the open instruction.
May you run the script below ?
It’s not a droplet but an applet.
When you run it it will ask you to choose a crtr file.
As I disabled the instructions supposed to trap the error, you will be able to see which instructions are correctly executed and where is the one failing.
set myLog to (path to desktop as text) & "myLog_goLym.txt"
set aFile to choose file with prompt "Choose a "crtr" file."
set {name:fileName, name extension:fileExtension} to info for aFile
my writeto(myLog, "fileName = " & fileName & linefeed & "fileExtension = " & fileExtension & linefeed, text, false)
if fileExtension = "crtr" then
if (count fileName) > 12 then
set baseName to text -12 thru -6 of fileName
my writeto(myLog, "point 1" & linefeed, text, true)
else
set baseName to text 1 thru -6 of fileName
my writeto(myLog, "point 2" & linefeed, text, true)
end if
my writeto(myLog, "baseName = " & baseName & linefeed, text, true)
set PDFPath to "mymountedVolume:"
tell application "MultiAd Creator Pro"
activate
--try
# aFile is an alias so there is no need to explicitely define the class
--open (aFile as alias)
my writeto(myLog, "point 3" & linefeed, text, true)
open aFile
my writeto(myLog, "point 4" & linefeed, text, true)
set theDoc to document 1
my writeto(myLog, "point 5" & linefeed, text, true)
set destFolder to PDFPath
my writeto(myLog, "point 6" & linefeed, text, true)
# Assuming that the filename match the original asker description,
# you are trying to export into : "mymountedVolume:1234567:myfilename1234567.crtr.pdf"
# Is it really what you want.
my writeto(myLog, "point 7, want to save in :" & linefeed & (destFolder & baseName & ".pdf") & linefeed, text, true)
display dialog "want to save in :" & linefeed & (destFolder & baseName & ".pdf")
--tell application "MultiAd Creator Pro" # No need for that, you are already speaking to this application
(*
export PDF current spread of theDoc saving in (destFolder & baseName & ":" & fileName & ".pdf") print order user order export method composite output color space CMYK stand in resolution 300 black and white compression use zip color image compression use JPEG quality 100 with embed no base 14 fonts, use doc size, binary encoding and compress text and line art without print as spreads, crop marks, registration marks, color bars, document notes, plate information, text blocks only and presentation mode
*)
-- end tell
my writeto(myLog, "point 8" & linefeed, text, true)
close front document saving no
my writeto(myLog, "point 9" & linefeed, text, true)
(*
on error e
display dialog "an error occured " & e
end try
*)
end tell
end if
#=====
(*
Handler borrowed to Regulus6633 - http://macscripter.net/viewtopic.php?id=36861
*)
on writeto(targetFile, theData, dataType, apendData)
-- targetFile is the path to the file you want to write
-- theData is the data you want in the file.
-- dataType is the data type of theData and it can be text, list, record etc.
-- apendData is true to append theData to the end of the current contents of the file or false to overwrite it
try
set targetFile to targetFile as «class furl»
set openFile to open for access targetFile with write permission
if not apendData then set eof of openFile to 0
write theData to openFile starting at eof as dataType
close access openFile
return true
on error
try
close access targetFile
end try
return false
end try
end writeto
#=====
It will create a text file named “myLog_goLym.txt” on the desktop.
If everything behaves flawlessly the text file will contain something like :
[format]fileName = myfilename1234567.crtr
fileExtension = crtr
point 1
baseName = 1234567
point 3
point 4
point 5
point 6
point 7, want to save in :
mymountedVolume:1234567.pdf
point 8
point 9[/format]
If all works well you will also get a dialog displaying something like :
want to save in :
mymountedVolume:1234567.pdf
If you post what you really get I will be able to know which instruction failed.
Yvan KOENIG running Sierra 10.12.5 in French (VALLAURIS, France) jeudi 18 mai 2017 17:21:15