Andrew Duncan
Andrew Duncan

Reputation: 13

Applescript will not open Excel 2011 workbook

Can somebody please tell me what is wrong with the following applescript

set sourceFile to (choose file with prompt "Choose source files" of type {"XLS6", "XLS7", "XLS8", "XLS", "TXT"} with multiple selections allowed without invisibles)
tell application "Microsoft Excel"
-- activate
open workbook workbook file name sourceFile
end tell

I am getting the following error

error "Microsoft Excel got an error: Can’t continue open workbook." number -1708

The script works if I hard code an individual file path, so problem must be in the set sourceFile line, but I need to be able to choose a file as it will not always be the same.

Upvotes: 1

Views: 1334

Answers (1)

adayzdone
adayzdone

Reputation: 11238

Try this:

set sourceFile to (choose file with prompt "Choose source files" of type {"XLS6", "XLS7", "XLS8", "XLS", "TXT"} with multiple selections allowed without invisibles) as string
tell application "Microsoft Excel"
open sourceFile
end tell

Upvotes: 3

Related Questions