I am trying to pick about 40 different values from Excel to use in my script, below is just a snippet…is there a better way to do this? Also is there a limit to how long a script can be? ie. number of characters?
Thanks,
set rowid to 0
set colid to 0
repeat with currentOrder from 1 to orderCount
set rowid to rowid + 1
tell application “Microsoft Excel”
set cellPosition to “r” & rowid & “c” & colid as string
set variable1 to FormulaR1C1 of Range cellPosition
set colid to colid + 1
set cellPosition to "r" & rowid & "c" & colid as string
set variable2 to FormulaR1C1 of Range cellPosition
set colid to colid + 1
set cellPosition to "r" & rowid & "c" & colid as string
set variable3 to FormulaR1C1 of Range cellPosition
set colid to colid + 1
In OS 9 I believe there is a 32K limit to the script length when using Script Editor. Other script editors allow longer scripts. I doubt your script needs to be nearly as long as you think. You could probably optimize your script significantly using a nested repeat. Something like:
I can see the values being picked up in my event log window. Is there a way to assign values from the result to individual variables so that they can be used in the rest of my script.
ie. set the result to variable 1, variable 2, variable 3 etc…
I am using the values to populate some online forms using IE, for example one of the values from Excel is assigned to a variable called ‘salutation’ in the script, this used to compare the values that are on the webform (salutationList), when a match is found the form is populated. There are about 5 different pages that script goes through to process one order.
In it’s current state the script is working ok in osx but ideally need to have it run on os9, unfortunately getting an error which is ‘text would be longer than its maximum possible length’ ?
set salutationList to {“Mr”, “Mrs”, “Miss”, “Ms”, “Dr”}
repeat with i from 1 to (count salutationList)
if item i of salutationList is equal to salutation then
–display dialog salutation
tell application “Internet Explorer”
Activate
do script “window.document.forms[2].salutation.options[ '” & i & “'].selected = true;”
do script “i=0”
end tell
end if
end repeat
No, you don’t need OS X for this. If you know the number of items in the_variables list (in the sample I gave above, you’ll end up with 30 items), then you can assign individual variables to the items in the list using the following convention (assuming the_variables has 3 values):