Q: 1700 error when try to get/read value from a xlxs
Hi,
I am a beginner and trying to write an AppleScript that will read the cell value from an xlsx file located in document folder. I am storing the values (username and password) in an Excel sheet and will pass the values to login into skype.
On my 1st step of the scripting, while retriving the value got 1700 error. Here is my script
Here is my code
tell application "Numbers"
set f to POSIX file "/Users/admin/Documents/DDSheet1.xlsx"
set x to value of range ("A2:A4") of Sheet1 of f as string
display dialog x
end tell
This is the error message
tell application "Numbers"
get value of range "A2:A4" of Sheet1 of file "Macintosh HD:Users:admin:Documents:DDSheet1.xlsx"
--> error number -1700 from Sheet1 of file "Macintosh HD:Users:admin:Documents:DDSheet1.xlsx" to specifier
Result:
error "Can’t make «class NMCv» of «class NmCR» \"A2:A4\" of Sheet1 of file \"Macintosh HD:Users:admin:Documents:DDSheet1.xlsx\" into type string." number -1700 from «class NMCv» of «class NmCR» "A2:A4" of Sheet1 of file "Macintosh HD:Users:admin:Documents:DDSheet1.xlsx" to string
Mac mini, OS X Yosemite (10.10.2)
Posted on Apr 20, 2015 3:00 AM
Hi,
You need to open the file in Numbers :
set f to "/Users/admin/Documents/DDSheet1.xlsx" as POSIX file as alias tell application "Numbers" launch set tDoc to open f tell tDoc set myList to value of cells of range "A2:A4" of table 1 of sheet 1 close saving no end tell end tell displayDialog_list(myList) on displayDialog_list(l) set tid to text item delimiters set text item delimiters to return set t to l as text set text item delimiters to tid activate display dialog t end displayDialog_list
If you have Excel :
set f to "/Users/admin/Documents/DDSheet1.xlsx" as POSIX file as text tell application "Microsoft Excel" launch set tdoc to open workbook workbook file name f with read only tell tdoc set myList to value of range "A2:A4" of sheet 1 -- or use the name of the sheet --> sheet "Sheet1" close end tell end tell displayDialog_list(myList) on displayDialog_list(l) set tid to text item delimiters set text item delimiters to return set t to l as text set text item delimiters to tid activate display dialog t end displayDialog_list
Posted on Apr 21, 2015 11:53 PM