...
tell application (path to frontmost application as string)
repeat
display dialog "Enter a name for file: " default answer file_name
set this_name to the text returned of the result
if this_name is not "" then exit repeat
end repeat
end tell
(* validate: this_name so that it ends with pdf *)
tell application "Finder"
set the name of this_file to this_name
set the target_file to ¬
(document file this_name of the parent_folder) as alias
end tell
tell this_name
set the saveplace to "Macintosh HD:Users:drclohite:a company:Accounts:banks:bank statements:2005:May 05:" & this_name
save document in saveplace as "pdf"
end tell
gives error:
Untitled.pdf doesnt understand the save message…
saveplace is a string. Save usually takes a file specification. Instead of this line:
save document in saveplace as “pdf”
try this line:
save document in file saveplace as “pdf”
Hi dennis
Thanks for your reply. I have tried your changes. Unfortunately it has not worked, have any more ideas I could try?
Model: powerbook
Browser: Internet Explorer 5.23
Operating System: Mac OS X (10.4)
I have changed the code slightly and I think I get a more telling error:
here is the change I made:
save document this_file in file "Macintosh HD:Users:drclohite:a company:Accounts:banks:bank statements:2005:May 05:"
Finder got an error: document (alias “Macintosh HD:private:tmp:printing.292.11:Untitled.pdf”) doesn’t understand the save message
I have seen some where else in this forum that it Applescript is not designed to save an alias.
I changed the code again to:
save document this_name in file "Macintosh HD:Users:drclohite:a company:Accounts:banks:bank statements:2005:May 05:"
Finder got an error: document “Unititled.pdf” doesn’t understand the save message.
doesn’t understand the save message?
Hi I am persisting with this and trying new things!
I have changed save line to:
save document this_file in file saveplace as "pdf"
I now get the error:
So it now seems to be trying to save the wrong file, i.e. the tmp print file, whereas perhaps I want to save the alias…
I think I am close from my other readings, anyone venture an opinion?
A document belongs to an application. You’ll normally tell the application to save the document and specify which document to save and where.
The few times I’ve tried the ‘save’ command, what’s worked for me is either an alias (if the file already exists) or a POSIX path. I’ve had no luck with file specifications or Mac OS paths. (Nor have I been able to make sense of the ‘as’ parameter.)
set the saveplace to POSIX path of "Macintosh HD:Users:drclohite:a company:Accounts:banks:bank statements:2005:May 05:" & this_name -- POSIX path to eventual file
tell appllication "My app"
save document "This doc" in saveplace -- as "pdf"
end