Re: Saving in Excel 2008
Re: Saving in Excel 2008
- Subject: Re: Saving in Excel 2008
- From: Stan Cleveland <email@hidden>
- Date: Wed, 11 Feb 2009 17:57:20 -0800
- Thread-topic: Saving in Excel 2008
On 2/11/09 4:26 PM, "Deivy Marck Petrescu" wrote:
> Stan, actually one problem I see with this syntax is, if "workbook 1"
> does not work as expected, I would have to keep track of the names of
> the workbooks.
The workbook index appears to be assigned in the order the documents are
opened. So "workbook 1" was opened first, "workbook 2" was opened second,
etc. If you close a workbook, the indices migrate downward to fill in the
missing one. That is, if you have five workbooks open and close workbook 3,
workbook 4 becomes workbook 3, and 5 becomes 4.
Also, bear in mind that the word "front" is synonymous with the index 1, so
in Excel 2008 the terms "front workbook" or "front document" will reference
the first-opened workbook and NOT the one that's currently frontmost. (By
the way, many Excel scripting commands fail when using "document" instead of
"workbook". The two terms are not interchangeable.)
Finally, though you may already know this, to bring a workbook frontmost,
use the "activate object" command:
activate object workbook 1
activate object workbook "text1.xls"
> that would not be good to automate something.
> But tomorrow I'll try : "save workbook active workbook in ..."
You could always use variables to reference your open workbooks:
set sourceDoc to workbook "Sales.xls"
set targetDoc to workbook "Accounting.xls"
activate object sourceDoc
This is reliable only when using workbook names, as shown here.
If you assign a workbook to a variable by index (workbook 2), the variable
assignment will change if you close a lower-indexed workbook, due to the
"migrating index" phenomenon mentioned above. That is, if you close workbook
1, the variable that referenced it will now point to the NEW workbook 1,
which was formerly workbook 2! Not good.
Interestingly, workbooks in Excel have no "index" nor "id" properties. The
only self-identifying properties of a workbook are "name" and "full name". I
suspect that's because of the transient nature of indices in Excel.
> Oh! Thanks for the "as workbook normal file format" I looked for
> something like that but could not find!
Considering that there are 34 file format options for Excel's save command,
it's not surprising that you didn't find it!
Stan C.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden