Applescript Overwrite is Excel X

S

salty_sohal

I'm trying to automate the conversion of several hundred files and each
one prompts me to overwite... how can I get around this in excel X. My
current line looks like this...

Save ActiveWorkbook In outFile As xlNormal without ReadOnlyRecommended
and CreateBackup

Thanks
 
B

Bob Greenblatt

I'm trying to automate the conversion of several hundred files and each
one prompts me to overwite... how can I get around this in excel X. My
current line looks like this...

Save ActiveWorkbook In outFile As xlNormal without ReadOnlyRecommended
and CreateBackup

Thanks
I'm not sure what the applescript text is, but to get excel to bypass the
overwrite warning (and do the overwrite anyway), in VBA the text is:
application.displayalerts=false
 
S

Salty

I added "without displayalerts" to the line and it accepts it as a
valid parameter, but I still get prompted to save.

Thanks for the suggestion though.

Jonathan
 
P

Paul Berkowitz

I added "without displayalerts" to the line and it accepts it as a
valid parameter, but I still get prompted to save.

Thanks for the suggestion though.

It's not a valid parameter: the 'without' is OK but the 'displayalerts' is
being parsed as a variable. That won't create a syntax error but it will
create a run-time error since it's an undefined variable. If the parameter
doesn't exist in the AppleScript dictionary, it doesn't exist.

There's no equivalent of "without displayalerts" in AppleScript for the Save
command (nor in the 2004 dictionary either). This is really an OS check -
there's no app where you can save over another file by AppleScript without
the dialogs. The way to do it is to save to another file name, then delete
or rm the original file, then change the file name to the original file
name in the Finder. The Finder occasionally gets a bit behindhand in these
operations so you should update the containing folder.

set outfilePath to "Mac HD:Users:me:Desktop:My Sheet.xls"
set tempPath to "Mac HD:Users:me:Desktop:temp.xls"

tell app "Microsoft Excel"
Save ActiveWorkbook In tempPath As xlNormal without ReadOnlyRecommended
and CreateBackup
end tell

tell app "Finder"
delete alias outfilePath
update alias "Mac HD:Users:me:Desktop:
set name of alias tempPath to "My Sheet.xls"
end tell



Instead of delete in the Finder (which puts the original in the trash) you
might prefer to:

set posixOutPath to quoted form of POSIX path of outfilePath
do shell script "rm " & posixOutPath
tell app "Finder"
update alias "Mac HD:Users:me:Desktop:
set name of alias tempPath to "My Sheet.xls"
end tell

--
Paul Berkowitz
MVP MacOffice
Entourage FAQ Page: <http://www.entourage.mvps.org/faq/index.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Microsoft Office you are using -
**2004**, X or 2001. It's often impossible to answer your questions
otherwise.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top