Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Feb 12, 2009, 05:56 PM   #1
hackthat
macrumors newbie
 
Join Date: Feb 2009
Applescript can't tell excel to open a workbook

I don't ask questions of forums without spending a great deal of time searching for answers first. But this one seems so easy yet it hasn't worked after hours of searching

I wan excel to open a workbook. I have excel 2004 and OSX

my code is

tell application "Microsoft Excel" to open workbook workbook file name "HD:User:internesktop:learningAS:SL__FORECAST.xls" with read only

the error I get is from excel saying
"SL__FORECAST.xls" cannot be accessed the file may be read-only, or you may be trying to access a read only location. Or the server the document is stored on may not be responding. "

I've tried it with "read only", and without. Tried it with different files that have been local and on a server. I've tried it with excel open and closed. I've tried changing the permissions on the file to be world read-writeable. I've tried all kinds of different syntax modifications among them:

tell application "Microsoft Excel" to open "HD:User:internesktop:learningAS:SL__FORECAST.xls

I keep getting the same error. Does applescript run as some kind of funny user?

thanks in advance,
-matt

"Applescript is so easy it's like writing in english" <-- ********
hackthat is offline   0 Reply With Quote
Old Feb 12, 2009, 10:38 PM   #2
HiRez
macrumors 601
 
HiRez's Avatar
 
Join Date: Jan 2004
Location: Western US
Yeah, I have the same problem with Excel files. Dunno why it does that but there is definitely a problem there (my files are not password protected and they reside on my local drive, and the same thing happens even with a new, blank .xls or .xlsx doc).

But, you can get around it like this, using the UNIX open command:

Code:
do shell script "open -a /Applications/Microsoft\\ Office\\ 2008/Microsoft\\ Excel.app ~/Desktop/test.xls"
(Make sure this command is NOT inside your tell block to Excel). Obviously, adjust your paths for the application and file as necessary (or build the path as a string). This should open any doc just as if you double-clicked it in the Finder, and will open the Excel documents that AppleScript won't directly.
__________________
Go outside, the graphics are amazing!
HiRez is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
AppleScript: How do I save multiple Excel sheets to one pdf using Applescript sbtaylor1 Mac Programming 0 Oct 29, 2013 12:38 AM
AppleScript: How do I save multiple Excel sheets to one pdf using Applescript sbtaylor1 Mac Applications and Mac App Store 0 Oct 29, 2013 12:32 AM
Display workbook name in Excel 2011 in Full Screen 3leggedpony Mac Applications and Mac App Store 0 Oct 4, 2012 01:15 PM
Applescript. Copy filtered cells in Excel Palkan Mac Programming 2 Jul 3, 2012 11:34 AM
Applescript with Excel tayjayt Mac Programming 1 Jun 27, 2012 06:44 PM

Forum Jump

All times are GMT -5. The time now is 03:46 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC