Automator/AppleScript and Excel 16.25 Script issue in Mac OS

Copper Contributor

I'm having issues getting Automator/Applescript to work with excel 16.25.

 

I customized the AppleScript from (https://discussions.apple.com/thread/5528059) to search for files containing an ISBN13 string (no dashes) in column B of an Excel worksheet with a wildcard search at the beginning and end of the file name. I'm basically searching for a filename that has the ISBN13 in it in part of the filename.

 

Search Directory is usually on a server mounted to the Mac. This has not changed.

 

Destination is usually the user’s desktop. When testing, it doesn’t matter I use the desktop or a folder not he root level of my hard drive.

 

The script used to run just great in the MacOS in various versions all the way up to and including MacOS 10.13 and in Excel versions up to Office 2016.

 

Now in MacOS 10.14 and Microsoft 16.25 it no longer works (I think it is an Excel issue as it does not work inExcel 16.25 in earlier versions of the MacOS). It just runs without any errors, but it does not copy the file.

 

I can run the commands in terminal (pasting int he search and destination path), and everything works just great (it finds the file and copies the file), so something tells me it’s something with the OS or Excel.

 

I have tried running it both as a Workflow and as a standalone app. When I run it as an app, I have granted it permission to control Microsoft Excel in Security and Privacy / Automation and allowed the saved AppleScript App to control Excel. But, it still does not work.

 

Thoughts? What am I missing?

 

 

 

on run {input, parameters}

 

 

 

set theDirectory to quoted form of POSIX path of (choose folder with prompt "Select Search Directory")

 

set theDestination to quoted form of POSIX path of (choose folder with prompt "Select Directory to Copy Files")

 

tell application "Microsoft Excel"

 

tell active sheet

 

tell used range

 

set rc to count of rows

 

end tell

 

set theList to get value of range ("B1:B" & rc) as list

 

repeat with theItem in theList

 

if contents of theItem is not {""} then

 

do shell script "find " & theDirectory & " -iname '*" & theItem & "*' -exec cp {} " & theDestination & " \\;"

 

end if

 

end repeat

 

end tell

 

end tell

 

 

 

return input

 

end run

0 Replies