This should be easy, I think, but nothing I’ve found has solved it. I have a script that opens a DOC or DOCX file and saves to an RTF file (which is then moved somewhere else and renamed, so the RTF file can go anywhere). I can’t figure out how to prevent the dreaded “grant access” dialog box, even though I think I’m creating a file object that should be able to solve it.
A StackOverflow post led me to try this (cnvFile is a file chosen by the user or dropped on the script):
try
set posixCnvFile to (POSIX path of cnvFile) as POSIX file
tell application "Finder"
set rtfPath to ((container of cnvFile) as text) & ("temp-temp-temp.rtf" as text)
end tell
on error err
display dialog "DEBUG: " & err
end try
try
tell application id "com.microsoft.Word"
set isRun to running
try
activate
set inFile1 to open file name posixCnvFile
alias rtfPath
save as inFile1 file name rtfPath file format format rtf with overwrite
close inFile1 saving no
on error err
display dialog "debug Word " & err
end try
if not isRun then quit
end tell
end try
But that still produces the grant access dialog. Can anyone tell me the (probably obvious) solution?