Re: Defining an excel function with applescript
Re: Defining an excel function with applescript
- Subject: Re: Defining an excel function with applescript
- From: Paul Berkowitz <email@hidden>
- Date: Tue, 14 Oct 2008 11:09:25 -0700
- Thread-topic: Defining an excel function with applescript
Title: Re: Defining an excel function with applescript
You can't script Excel functions, as such.
You have two alternatives usually:
- Do the job with straight AppleScript, when that is possible. In the case you're asking, which is dead simple, Eric shows you how to do it. In that case, the only bit of Excel scripting needed is to get the value. In other cases, you would use Excel's AppleScript dictionary to do all sorts of things, hundreds of them.
- When the only, or best way, is to use an Excel function, you can simply set the value of any cell not already being used to the function text as you would in the UI (i.e. NOT VBA), and then get the value again, which should now give you the result. (Just like in the UI when you type in the function then press return and you see the result in the cell.) Then use the result as you will and set the value of the cell back to "" to clear it. For complex functions, this will be the fastest way to get the result.
--
Paul Berkowitz
From: steen knudsen <email@hidden>
Date: Tue, 14 Oct 2008 19:08:50 +0200
To: AppleScript-Users <email@hidden>
Subject: Defining an excel function with applescript
Defining an excel function with applescript
When using excel on windows I have been able to apply a function by the use of Visual Basic.
The function enables me to get the reverse of a text string in one cell - e.g. "ABCDEFG" -> "GFEDCBA"
I am now using Excel 2008 12.1.2 on Mac. But I would still like to be able to use this function. Can I define this function by using Apple Script?
If it is possible, how do I do it?
Thanks in advance for your help
Steen Knudsen
The Visual Basic Code for the function follows below:
Function ReverseCell(Rcell As Range, Optional IsText As Boolean)
Dim i As Integer
Dim StrNewNum As String
Dim strOld As String
strOld = Trim(Rcell)
For i = 1 To Len(strOld)
StrNewNum = Mid(strOld, i, 1) & StrNewNum
Next i
If IsText = False Then
ReverseCell = CLng(StrNewNum)
Else
ReverseCell = StrNewNum
End If
End Function
_______________________________________________
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
_______________________________________________
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