VB code to Applescript help

D

dave_j

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

Hi, I have a couple of Excel 2003 spreadsheets that contain VB Macros which I am trying to convert to Applescript. I have managed one but am struggling on the second. It looks like it should be simple enough but I am just not getting it!

Here is the VB code:

Sub Button1_Click()
Range("F10").Value = Range("I4").Value * Range("D9").Value
Range("F5").Value = Range("H5").Value
Range("F6").Value = Range("H6").Value
Range("F7").Value = Range("H7").Value
Range("F8").Value = Range("H8").Value
Range("F10").Value = "=SUM(F4:F8)"
End Sub

Here is what I have done so far, although I don't think it is correct.

tell application "Microsoft Excel"

set value of cell "F10" to (value of range "I4") * (value of range "D9")
set value of cell "F5" to value of range "H5"
set value of cell "F6" to value of range "H6"
set value of cell "F7" to value of range "H7"
set value of cell "F8" to value of range "H8"
set value of cell "F10" to value of "=SUM(F4:F8)"
end tell

If someone could advise of the correct code, I would be eternally grateful.
 
B

Bob Greenblatt

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

Hi, I have a couple of Excel 2003 spreadsheets that contain VB Macros which I
am trying to convert to Applescript. I have managed one but am struggling on
the second. It looks like it should be simple enough but I am just not getting
it!

Here is the VB code:

Sub Button1_Click()
Range("F10").Value = Range("I4").Value * Range("D9").Value
Range("F5").Value = Range("H5").Value
Range("F6").Value = Range("H6").Value
Range("F7").Value = Range("H7").Value
Range("F8").Value = Range("H8").Value
Range("F10").Value = "=SUM(F4:F8)"
End Sub

Here is what I have done so far, although I don't think it is correct.

tell application "Microsoft Excel"

set value of cell "F10" to (value of range "I4") * (value of range
"D9")
set value of cell "F5" to value of range "H5"
set value of cell "F6" to value of range "H6"
set value of cell "F7" to value of range "H7"
set value of cell "F8" to value of range "H8"
set value of cell "F10" to value of "=SUM(F4:F8)"
end tell

If someone could advise of the correct code, I would be eternally grateful.
What happens when the apple script is run? In the Apple script, make sure
that the correct worksheet is active.
 
D

dave_j

am getting the following error:

Can't get value of "=SUM(F4:F8)"

Have i got the syntax of the SUM line wrong?
 
L

Laroche J

am getting the following error:

Can't get value of "=SUM(F4:F8)"

Have i got the syntax of the SUM line wrong?

Try
set Value of Cell "F10" to "=SUM(F4:F8)"

JL
Mac OS X 10.4.11
Office v.X 10.1.9, Office 2008 trial
 

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