Using Applescript with excel

M

martin.a.john

My company has recently upgraded to mac office 2008 and I discovered
there is no support for the excel macro's I previously had in place
and am now trying to get to grips with applescript to perform the same
functions.

I have faced a problem when trying to select an undefined amount of
rows and perform a simple copy paste to another workbook. I used to
use the xldown command in vba put cannot find something like this in
apple script. I am also having a hard time with a simple copy from one
workbook and pasting to another.

If anyone can provide me with some guidance with the above this could
help solve a few of my problems.

Maritn
 
J

JE McGimpsey

My company has recently upgraded to mac office 2008 and I discovered
there is no support for the excel macro's I previously had in place
and am now trying to get to grips with applescript to perform the same
functions.

I have faced a problem when trying to select an undefined amount of
rows and perform a simple copy paste to another workbook. I used to
use the xldown command in vba put cannot find something like this in
apple script. I am also having a hard time with a simple copy from one
workbook and pasting to another.

If anyone can provide me with some guidance with the above this could
help solve a few of my problems.

There are a number of ways to do this. One way:

tell application "Microsoft Excel"
set rDest to range "[Workbook2]Sheet1!A1"
set rStart to range "[Workbook1]Sheet1!A2"
tell rStart
set nRowsToCopy to (first row index of ¬
(get end cell 1 direction toward the bottom)) - ¬
(first row index of cell 1) + 1
set rCopy to (get resize cell 1 row size nRowsToCopy)
end tell
copy range rCopy destination rDest
end tell


Alternatively, if you're just trying to copy values:

tell application "Microsoft Excel"
set rDest to range "[Workbook2]Sheet1!A1"
set rStart to range "[Workbook1]Sheet1!A2"
tell rStart
set rCopy to (get resize cell 1 row size (first row index of ¬
(get end cell 1 direction toward the bottom)) - ¬
(first row index of cell 1) + 1)
end tell
tell rCopy
set value of (get resize rDest row size (count rows)) to ¬
get its value
end tell
end tell
 

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