I am working on a Filemaker script that needs to open the URL of a Googlesheets spreadsheet, go to a given cell (B2), insert the data from an FM variable and then copy the data from a range of cells in the spreadsheet (F11-H171) before pasting back into FM. I have made KM that sort works but needs perfecting. Is there a way to go to directly to cell B2. At the moment I am using "Click", but if the Googlesheet isn't displaying the upper left corner of the spreadsheet, it clicks the wrong cell. Is there a way of avoiding that? I am also using a series Type Shift Right and Type Shift down, but once again if the Googlesheets isn't positioned correctly I get erroneous results. Any ideas for rendering this more precise and more streamlined?
The following may work, but it depends on the cells of your spreadsheet, because Google Sheets seems to define the modified arrows commands to work different if your sheet contains data or not. Give it a try.
tell application "Safari" to activate
delay 1
tell application "System Events"
key code 123 using {command down} -- left arrow
delay 0.5
key code 126 using {command down} -- up arrow
delay 0.5
key code 124 -- right
delay 0.5
key code 125 -- down
end tell
Have you tried using the "Go to range" keyboard shortcut? ⌃G
brings that up and you can then insert the cell reference and hit Return to go there.
Assuming you have your value from FileMaker on the Clipboard, ready to paste, and the Sheet is in the frontmost Safari window then something like this will do it (you may have to adjust the pauses to give things time to happen):
Googlesheet Routine.kmmacros (6.3 KB)
1 Like
Thanks so much Nige_S. That works a treat.