0

I want to fill a webform (text filed) from a page i open in Safari with the text from a excel cell. I have managed to do a script to copy the cell content to clipboard but i do not know how to use this to fill the form.

I do not have much experience and i found the below code to input a specific text. How do i change it to do what i need?

tell application "Safari" 
do JavaScript "document.getElementById('Exampleid').value = "Clipboard";" in document 1 
end tell 

Note: the script in total is bigger and it goes in a loop each time selecting a different cell in excel to copy into the same form but at a different address.

1

Instead of copying the cell text to the clipboard, save it in a variable and then apply it to the form.

Here's a helpful tutorial that will give you the answer, step by step.

The code would be very similar to yours, using the variable:

tell application "Safari"
        do JavaScript "  document.getElementById('" & IdVar & "').value ='" & theCellValue & "';" in document 1
end tell 

To set the variable form Excel use this:

tell application "Microsoft Excel"
        set CellValueX to (value of cell ColX of row RowX)
end tell

And, of course, wrapt it all in a repeat loop.

I hope this helps.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .