Hottest Free Downloads - DownloadPipe.com Over 197,000 downloads! Bookmark Now!
DownloadPipe.com - New Downloads Every Minute
 SEARCH:
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Applescript Syntax

 
   Mac (Home) -> Mac Excel RSS
Next:  AIM Mail on Safari: "Too many redirects&quot..  
Author Message
fwbmorison

External


Since: Oct 14, 2009
Posts: 2



(Msg. 1) Posted: Wed Oct 14, 2009 12:54 pm
Post subject: Applescript Syntax
Archived from groups: microsoft>public>mac>office>excel (more info?)

Version: 2008
Operating System: Mac OS X 10.5 (Leopard)
Processor: Intel

I'm very new to Applescript, so I am sure I am overlooking some simple rule of syntax, but I would appreciate a pointer.

This compiles:
tell application "Microsoft Excel"
activate
(* Work with active sheet *)

set myRange to current region of active cell
set myTotal to get offset myRange row offset 9 column offset 1


select myTotal

end tell

As does this:

tell application "Microsoft Excel"
activate
(* Work with active sheet *)

set myRange to current region of active cell
set myTotal to get offset myRange row offset count of rows of myRange


select myTotal

end tell

but when I try to add a column offset in the second example, the applescript compiler tells me about a syntax error at the word column - expected end of line, etc. but found class name

e.g this won't compile
tell application "Microsoft Excel"
activate
(* Work with active sheet *)

set myRange to current region of active cell
set myTotal to get offset myRange row offset count of rows of myRange column offset 1


select myTotal

end tell

Thanks
Back to top
Login to vote
John McGhie

External


Since: Jun 12, 2007
Posts: 759



(Msg. 2) Posted: Thu Oct 15, 2009 7:25 am
Post subject: Re: Applescript Syntax [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Yeah, well I'm struggling too, because I don't do AppleScript, but I suggest
that you need to return rows and columns to a single OFFSET statement:

Maybe something like:
myRange row offset((count of rows of myRange), columns 1)

How do you know which is the active sheet? If you simply tell a workbook to
activate, will the active sheet not become the "first" sheet? So should you
not activate the sheet you want by name?

And how do you know which is the active cell? When you activate a sheet,
the active cell will be the cell last selected, won't it? Which is not
really safe...

I would be inclined to construct a formula that populates a specific cell
with the value you want, then create a Defined Name for that cell.

Then you can simply "ask" Excel directly for the total in "TheTotalIWant"
and get it, without your AppleScript needing to work out where it is Smile

Note: Names are workbook-wide by default, but can also be created as
specific to a worksheet. In this case, you would want the global version,
so you do not have to work out which sheet you are on.

Look up "Dynamically Expanding Ranges"
http://www.contextures.com/xlNames01.html


Cheers

On 15/10/09 6:54 AM, in article 59b7e94f.-1 DeleteThis @webcrossing.caR9absDaxw,
"fwbmorison@officeformac.com" <fwbmorison DeleteThis @officeformac.com> wrote:

> Version: 2008
> Operating System: Mac OS X 10.5 (Leopard)
> Processor: Intel
>
> I'm very new to Applescript, so I am sure I am overlooking some simple rule of
> syntax, but I would appreciate a pointer.
>
> This compiles:
> tell application "Microsoft Excel"
> activate
> (* Work with active sheet *)
>
> set myRange to current region of active cell
> set myTotal to get offset myRange row offset 9 column offset 1
>
>
> select myTotal
>
> end tell
>
> As does this:
>
> tell application "Microsoft Excel"
> activate
> (* Work with active sheet *)
>
> set myRange to current region of active cell
> set myTotal to get offset myRange row offset count of rows of myRange
>
>
> select myTotal
>
> end tell
>
> but when I try to add a column offset in the second example, the applescript
> compiler tells me about a syntax error at the word column - expected end of
> line, etc. but found class name
>
> e.g this won't compile
> tell application "Microsoft Excel"
> activate
> (* Work with active sheet *)
>
> set myRange to current region of active cell
> set myTotal to get offset myRange row offset count of rows of myRange
> column offset 1
>
>
> select myTotal
>
> end tell
>
> Thanks

This email is my business email -- Please do not email me about forum
matters unless you intend to pay!

--

John McGhie, Microsoft MVP (Word, Mac Word), Consultant Technical Writer,
McGhie Information Engineering Pty Ltd
Sydney, Australia. | Ph: +61 (0)4 1209 1410
+61 4 1209 1410, mailto:john@mcghie.name
Back to top
Login to vote
fwbmorison

External


Since: Oct 14, 2009
Posts: 2



(Msg. 3) Posted: Thu Oct 15, 2009 8:17 pm
Post subject: Re: Applescript Syntax [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Thanks John - unfortunately, the brackets thing didn't work. However, I will try to translate the VBA in the link you sent me to applescript and see whether than will work.
Back to top
Login to vote
John McGhie

External


Since: Jun 12, 2007
Posts: 759



(Msg. 4) Posted: Fri Oct 16, 2009 3:25 am
Post subject: Re: Applescript Syntax [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Yeah, sorry, I just don't know AppleScript. But I would expect that the
error is that you need to give OFFSET two arguments: Row and Column.

Cheers


On 16/10/09 2:17 PM, in article 59b7e94f.1 RemoveThis @webcrossing.caR9absDaxw,
"fwbmorison@officeformac.com" <fwbmorison RemoveThis @officeformac.com> wrote:

> Thanks John - unfortunately, the brackets thing didn't work. However, I will
> try to translate the VBA in the link you sent me to applescript and see
> whether than will work.

This email is my business email -- Please do not email me about forum
matters unless you intend to pay!

--

John McGhie, Microsoft MVP (Word, Mac Word), Consultant Technical Writer,
McGhie Information Engineering Pty Ltd
Sydney, Australia. | Ph: +61 (0)4 1209 1410
+61 4 1209 1410, mailto:john@mcghie.name
Back to top
Login to vote
Display posts from previous:   
Related Topics:
1 to many relationship syntax - In my spreadsheet, I am trying to match the well API with RFT API. There are 150 rows in RFT spreadsheet. If RFT API match with well API then it will add new RFT and this new RFT will continue to read the same RFT API and generate the RFT data BEFORE EXI...

VBA to Applescript - Version: 2008 Hello, I 've found and edited a VBA for my work. but now i cant use it with our MacBook Pro. it has Office 2008 for Mac and it says " Office for Mac does not support VBA script ". Anyone can help me to convert this script to Ap...

get text of comment in Applescript - How does one get the text of an Excel 2004 comment in Applescript? I've tried such things as "get value of Excel comment", "get text of Excel comment", etc, with no luck. Here's an example based on the sample on page 83 of the Excel ...

AppleScript recorder in version X - Is there a AppleScript recorder in verison v.X ? If one is doing a lot of AppleScript/Excel programming , is it worth one's while to buy it? Or are you better off writing from scratch or "translating" VBA? Thanks.

Excel AppleScript Dictionary - I started converting my Personal Macro Workbook to AppleScript and ran into a problem with the Dictionary. There seems to be no AppleScript term for the VBA WorksheetFunction object. What have other people done about the problem? Cheers, Tom :-)
       Mac (Home) -> Mac Excel All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum
Categories:
 Windows Forums
 Game Forums
 Linux Forums
  Mac Forums
 PDA Forums
 Mobile Forums
  Top  |  Store  |  RSS Feeds RSS  |  Data Feeds  |  Advertise  |  Submit  |  Bookmark  |  Newsletter  |  Contact