Excel 2004 & applescript

S

stafair

Hello,

I'm a newbie and i would like to open, with applescript, a new workbook
based on a template.

Thanks a lot.
 
P

Paul Berkowitz

I'm a newbie and i would like to open, with applescript, a new workbook
based on a template.

Just use

open "Mac HD:Applications:Microsoft Office 2004:Templates:My
Templates:File Name.xlt"

or

open workbook workbook file name "Mac HD:Applications:Microsoft Office
2004:Templates:My Templates:File Name.xlt"

It' true (and unfortunate) that it opens with the template's name including
an .xlt extension of any, rather tan as "Workbook5" or whatever. But by
command-clicking on the title bar of the window you'll see it's not actually
the saved template file - no folder hierarchy appears as it does with saved
files. (Try clicking the title of an opened saved file if you don't know
what I'm talking about.) It's a new instance - not the original template.
You can modify it however you want. If you go to Save manually, you'll see
that it is set to save as an .xls Workbook, not a template. If you want to
save by AppleScript, you can use either the 'save' command in Standard Suite
with the 'as' parameter to be safe:

save active workbook in "Mac HD:Users:stafair:Documents:New File.xls" as
workbook normal

or use the 'save workbook as' command from the Excel Suite using the file
format parameter:

save workbook as active workbook file name "Mac
HD:Users:stafair:Documents:New File.xls" file format workbook normal file
format

(I think it would save as Workbook even without specifying the file format,
since Workbook is default.)

To save it as a template -- i.e. to modify the template and save it - might
in fact be trickier sine there's no 'replacing yes' parameter. I'll look
into that one.

So basically, you open the template the same way whether you're planning to
use it as a new workbook - which happens naturally - or as the template
(which doesn't happen). It's how you save it that determines whether it's a
new workbook or not. By default it is. I don't think you even need the 'as
workbook normal' or ' file format workbook normal file format' - the default
will be the same. But is is unfortunate that when you 'open' or 'open
workbook' the window name is the name of the template and not "Workbook4" as
in the UI. I'll file a bug on that and inquire if there's some other way to
do it.

--
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.
 
S

stafair

Thank you for the detailed explanations

On 2004-10-23 19:43:07 +0200, Paul Berkowitz <berkowit@spoof_silcom.com> said:
 

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